Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Are there either any xUnit (or otherwise) design patterns or anti-patterns for testing threaded code?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Have you seen a http://xunitpatterns.com? A lot of great material there.

In my experience dealing with threaded behavior in tests just makes things needlessly complicated and not worth the effort. Try to isolate tasks from each other by using mocks/stubs as much as you can.

There is one particular pattern however that helped me a lot: design by contract. Which I implemented by inserting assertions in the application code and stress testing the system in attempt to trigger their violations.

YMMV of course, but for my projects this approach (isolation and stress testing) proved to be more effective than trying to write tests for specific use cases.

share|improve this answer
    
+1 Yes, I do have the XUnit Test Patterns book. Great resource indeed. –  Sardathrion Dec 6 '11 at 13:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.