# Memcache wrapper testing

**URL:** <https://www.ruby-forum.com/t/memcache-wrapper-testing/109577>\
**Category:** Ruby\
**Created:** [July 17, 2007, 1:17am UTC](https://www.ruby-forum.com/t/memcache-wrapper-testing/109577 "2007-07-17T01:17:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [July 17, 2007, 1:17am UTC](https://www.ruby-forum.com/t/memcache-wrapper-testing/109577/1 "2007-07-17T01:17:14Z")

</div>

I have a wrapper class for memcache-client (adds a little extra  
functionality for something specific I need). Does anyone have any good  
ideas for how to do unit testing on it?

The issue I have is that the memcache will become full of data from each  
functional test I run. It would be nice to have a “clean slate” each  
time I run. To me, the obvious thing would be to start and stop a  
memcached server for each of my tests, but that seems like a major pain.  
Is there something I’m missing like a clear\_memcache function or  
something?

Thanks!

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [July 17, 2007, 5:25am UTC](https://www.ruby-forum.com/t/memcache-wrapper-testing/109577/2 "2007-07-17T05:25:49Z")

</div>

On 7/16/07, David W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a wrapper class for memcache-client (adds a little extra  
> functionality for something specific I need). Does anyone have any good  
> ideas for how to do unit testing on it?

Use mocks. Check the cache\_fu tests, which run against mocks and a  
real memcached server.

[http://require.errtheblog.com/plugins/browser/cache\_fu](http://require.errtheblog.com/plugins/browser/cache_fu)

---

<div class="post-metadata">

**Author:** ![dawillis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dawillis](https://www.ruby-forum.com/u/dawillis)\
**Post date:** [July 17, 2007, 10:34am UTC](https://www.ruby-forum.com/t/memcache-wrapper-testing/109577/3 "2007-07-17T10:34:36Z")

</div>

On Jul 16, 2007, at 16:18, David W. wrote:

> pain.  
> Is there something I’m missing like a clear\_memcache function or  
> something?

Look at how the memcache-client tests are written. They never touch  
a server.
