« Return to Thread: [jira] Created: (JMOCK-214) Fail fast when run concurrently

[jira] Commented: (JMOCK-214) Fail fast when run concurrently

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View in Thread


    [ http://jira.codehaus.org/browse/JMOCK-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=167493#action_167493 ]

Sebastian Sickelmann commented on JMOCK-214:
--------------------------------------------

There is a way to "control" threads created and started by third-party libraries. It is a litle bit tricky but it works. I use it in my project mockinject.

In mockinject i use ThreadLocal variables to store individual state, so every unittest can run it its own thread. To adress the problem of rescueing the ThreadLocal to newly created threads (also from third-party libraries), I catch all Thread-creation-steps and inject own threads that does the rescueing process. It is a little bit tricky and slows down the execution-speed a bit but works realy nice (have some problems with swing-event-thread but that is another story)



> Fail fast when run concurrently
> -------------------------------
>
>                 Key: JMOCK-214
>                 URL: http://jira.codehaus.org/browse/JMOCK-214
>             Project: jMock
>          Issue Type: Improvement
>          Components: Library
>         Environment: any
>            Reporter: Douglas Squirrel
>
> Steve F suggested I file this enhancement when we saw this behaviour at youDevise.
> When you build a test that executes in multiple threads, and it calls methods on a mocked object, you can get odd behaviour. For instance, our exactly(N).of expectation failed no matter how we set N or how many threads actually called the method (including N).
> This is by design, but it would help newcomers to JMock who don't know this if they got a clear failure instead of odd behaviour (as you do with ConcurrentModificationException for non-threadsafe collections). For instance, JMock could record the thread id on construction of the Mockery and then check the thread ID is the same on future invocations. (Not sure what performance effect this would have though.)
> Happy to try writing a unit test though I'm not sure if you want to start running multiple threads in your test suite.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: [jira] Created: (JMOCK-214) Fail fast when run concurrently