[mocha-developer] Problem with Mocks: "random" tests failing

Laurent Francioli laurent.francioli at gmail.com
Mon Jul 9 04:27:55 EDT 2007

Hi all!

I am pretty new to Mocha and I am writing tests that use Mocks quite a bit.
I am having a weird behavior with some of the tests for a specific class:

I wrote a first couple of tests that were passing and then when adding a 3rd
one, the first tests begun to fail. Now what's bugging me even more is that
if I run them in debugger mode with breakpoints on the functions where the
errors are, they either pass or fail on other expectations.

A few more interesting things are:
- These tests all use pretty much the same functions
- The class under test launches threads and some of the expectations are
within the threads
- Only expectations fail like this (all assert always pass)
- Commenting "random" lines (like removing an expect on no errors should be
logged) can change the outcome of the tests

So it looks like either I'm not doing the proper setup/teardown actions or
the threads are posing a problem. In my setup I always reload (require) all
the libraries I need, and create fresh objects. In the teardown I get rid of
the objects under test.

I am using the mocha gem 0.5.1 and these problems are really driving me

Please let me know if you ohave any hints for me! I'll be happy to give more
information if required.

Thanks alot,

More information about the mocha-developer mailing list