我正在使用Spiratest JUnit集成库。它正常的测试用例正常工作,测试结果按预期传输到SpiraTest。
现在,我正在添加参数化测试,这是JUnit 4的一个功能。当我将SpiraTest注释添加到参数化测试中,并使用SpiraTest自动测试集成指南中记录的Main类运行它时,它失败。我收到以下错误消息: java.lang.NoSuchMethodException:org.test.FibonacciTest.test0
SpiraTest JUnit集成库是否支持参数化测试?如果是,我如何在SpiraTest JUnit集成库中使用参数化测试?
这是我的代码,让您了解我尝试完成的任务:
@RunWith(Parameterized.class)
@SpiraTestConfiguration(url = URL, login = USER, password = PWD, projectId = PROJECT_ID)
public class FibonacciTest {
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 }, { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });
}
private int fInput;
private int fExpected;
public FibonacciTest(int input, int expected) {
fInput = input;
fExpected = expected;
}
@Test
@SpiraTestCase(testCaseId=21966)
public void test() {
assertEquals(fExpected, compute(fInput));
}
private int compute(int fInput2) {
return 1;
}
}
这是主要课程:
public class SpiraApplicationMain {
public final static String URL = "";
public final static String USER = ";
public final static String PWD = "";
public final static int PROJECT_ID = 0;
/**
* Entry point for command line execution
*
* @param args
* The command line arguments
*/
public static void main(String[] args) {
// Instantiate the JUnit core
JUnitCore core = new JUnitCore();
// Add the custom SpiraTest listener
core.addListener(new SpiraTestListener());
// Finally run the test fixture
core.run(FibonacciTest.class);
}
/**
* Entry point for JUnit 4.x runners
*
* @return Handle to the test framework
*/
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(FibonacciTest.class);
}
}