junit

Parameterized Tests

Tag(s):

Sometimes you want to use a generic test method to test with different sets of values. But if you use a loop to do that, then the whole method will fail if 1 of the set of values fails. As a result, it is not helpful as you don't know which specific set of values failed. JUnit report will only show that the generic test method as a whole failed. But if you are writing 1 test method per set of values, then there is a lot of codes, which is not efficient and practical.

Execution order of JUnit's annotations

Tag(s):

/**
 * Show the execution order of each annotations.
 * Given this test, the methods will execute in the following order:
 * oneTimeSetUp()
 * setUp()
 * testMyFunction1()
 * tearDown()
 * setUp()
 * testMyFunction2()
 * tearDown()
 * oneTimeTearDown()
 * 
 * **NOTE**: JUnit doesn't guarantee the execution order of the test functions(@Test).
 * 
 */
Subscribe to RSS - junit