Reputation: 7327
I'm wondering what are the strengths and weaknesses of using JUnit for code testing? For example, I don't believe it is good for testing concurrency. Any input would be appreciated. Thanks
Upvotes: 0
Views: 1045
Reputation: 7731
Just a note for people searching concurrency - there is a unit test framework designed to test concurrency (something-Unit). A Google search is not finding it for me, but I know it exists, read about it recently.
Upvotes: 0
Reputation: 7297
JUnit has two strengths:
Testing concurrent code is possible in JUnit, but it doesn't provide any particular support for it. You have to manage your threads and arrange interleaving scenarios yourself.
That said, I believe there are tools out there, and if you adopt JUnit, you'll likely find that is the expected scenario from test helpers like hamcrest matchers.
Upvotes: 2
Reputation: 308743
Testing concurrent code is hard, no matter what you choose.
TestNG has a mechanism for creating multiple threads and running them in a concurrency test. I believe it'd be possible to create a bunch of FutureTasks in a JUnit test to exercise a method. It's just not supported in JUnit 4.
The strengths? Here are a few:
Upvotes: 3