What are the unit testing frameworks available in java? [closed]
开发者_如何学JAVA
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionWhat are the technologies out there? (I only know of JUnit) What is the most popular? Can you please explain the pros/cons of each?
JUnit and TestNG are the main unit test frameworks.
Comparison can be found here - http://www.mkyong.com/unittest/junit-4-vs-testng-comparison
I've used JUnit in most places I've worked, it seems to be the standard, but there are some nice things in TestNG.
I've used the following in combination with JUnit to facilitate testing:
- Mockito for mocking objects - http://code.google.com/p/mockito/
- Hamcrest assertions for more readable assertions - http://code.google.com/p/hamcrest/
- Twip for parameterized testing, the JUnit stuff isn't the greatest, in fact TestNG does this better as well - http://twip.sourceforge.net/
JUnit and TestNG are the most popular. JUnit being the de-facto standard, and TestNG providing some extra features.
There are a lot of "add-on" framework for specific kinds of testing, typically these depend on JUnit. Examples:
- DBUnit - for testing code that accesses a database
- JFCUnit - for testing Swing apps
- HTMLUnit - for testing web apps
Heres is a list
- JUnit
- Cactus
- StrutsTestCase
- JFCUnit 10 javascript framework to download
- TestNG
- jMock
- Grinder
- Jetif
- Unitils
- p-unit
- XMLUnit
- Ejb3Unit
- FEST-Swing
- Ripplet
- Feed4JUnit
- Jubula functional testing tools
- JsTestDriver
- Citrus Testframework 19.JBehave
- JCrawler – load testing framework
List Source
You can find good comparison between JUnit and TestNG here:
http://hi.baidu.com/auraro816/blog/item/efe0574d03db6df4d72afc9f.html
if you have time to listen podcast try with Basement coders -Episode 21 – Interview with Cedric Beust creator of testNG
Apart from all the listing above, You can include selenium as well. This is widely used in industry for Java UI testing.
精彩评论