I've used TestNG and JUnit. What other frameworks are out there? What makes them special and/or different from the rest?
|
|
Scala Specs gets my vote! :-) Specs is a behavior-driven-development testing framework written in Scala. It can be used to write tests for Java and Scala. It was inspired by RSpec - a testing framework very popular in the Ruby world. An example test written in Specs:
Impressive, isn't it? :-) |
|||||||||||
|
|
I suggest to use TestNG as core unit test framework for Java project, because TestNG is more advance in parameterize testing, dependency testing and suite testing (Grouping concept). TestNG is meant for high-level testing and complex integration test. Its flexibility is especially useful with large test suites. In addition, TestNG also cover the entire core JUnit4 functionality. It’s just no reason for me to use JUnit anymore. |
|||||
|
|
A whole new world of testing frameworks for Java exists via JRuby. For example: Test::Unit, RSpec, Shoulda, ZenTest, RSpec Mocks, Mocha and Cucumber. I think it is great to write Java tests in the elegant Ruby language. Of course, this depends if you are in the mood of having multiple languages in your SCM. |
|||
|
|
|
I can recommend scalacheck (easily confused with scalatest). You write Specifications, and the framework builds the testcases randomly for you, and when violating a check it will try to simplify the test, to find the simplest way to fail. Sample code from the website:
|
||||
|
|
|
If you need this for choosing a unit test framework, then I would suggest the following: Choose the one the rest of your team uses. If your team does not use one, or you do not have a team, use the one your IDE supports out of the box in the default configuration. If you still have not decided, then start with JUnit 4 which is the de-facto standard. |
|||
|
|
|
With recent JUnit versions, Hamcrest was integrated into the library. Hamcrest adds additional matchers which improve readability but otherwise doesn't change the semantics of your tests. It therefore might be a good addition for your test setup.
|
|||
|
|