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

David Chelimsky dchelimsky at gmail.com
Mon Jul 9 11:21:05 EDT 2007


On 7/9/07, Laurent Francioli <laurent.francioli at gmail.com> wrote:
> 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
> craaaaazy!
>
> Please let me know if you ohave any hints for me! I'll be happy to give more
> information if required.

I think we'd really need specific examples to be able to help you. Is
it possible for you to post the code? Both the test code and the code
being tested would be most helpful.

>
> Thanks alot,
> Laurent
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>


More information about the mocha-developer mailing list