I am reading the inputs like testname, expected result, parameters from xml file and depends on inputs(testname), calling the respective testmethod multiple times. for example
public void test_calc() throws Exception{
............
.......
if(testName.equalsIgnoreCase("addition")){
addition(table, expectedResult);
}
else if(testName.equalsIgnoreCase("multiplication")){
multiplication(table, expectedResult);
}
else if(testName.equalsIgnoreCase("substraction")){
substraction(table, expectedResult);
}
I am calling same method multiple times depends on XML inputs. I am using ANT to run this Junit tests and all tests are executed correctly.But in the report it showing as single test with test开发者_如何学编程name test_calc not the addition, multiplication etc. I would like to get the report for each test run with pass/fail result.Can someone please help me on this?
This is the way JUnit reports are designed. Each test case (== test method is reported once).
You get separate reports by defining separate methods. You don't need the 'name' of the test case for reporting. The name is purly a human readable name attached to a test class or suite. This is how to write your test cases:
public void testAddition {
addition(table, expectedResult);
}
public void testMultiplication {
multiplication(table, expectedResult);
}
public void testSubstraction {
substraction(table, expectedResult);
}
精彩评论