【发布时间】:2013-12-16 06:51:55
【问题描述】:
我需要运行一个参数化测试,它可以按预期正常工作,但这里需要关注的是,在我们的框架中,我们有自己的自定义侦听器类,它扩展了 RunListener 并覆盖了所有方法。但是当我将测试作为参数化测试运行时,没有任何方法被覆盖。但如果我在没有参数的情况下运行测试,同样可以正常工作。
下面是我的 CustomJunitListener
{
/**
* Class used to do some report regarding the JUnit event notifier
*/
public class CustomJUnitListener extends RunListener {
SeleniumTest test = null;
public void setSeleniumTest(SeleniumTest test) {
this.test = test;
}
/** {@inheritDoc} */
@Override
public void testFinished(Description description) throws Exception {
if (test != null) {
test.postExecution();
}
}
}
当我运行参数化测试时,不会调用 postExection 方法。我希望在完成测试的每组参数后调用 postExection 方法。
下面是我的硒测试
@RunWith(Parameterized.class)
public class Test_Script extends SeleniumTest{
private String testName;
private String from;
private String to;
public Test_Script(String testName , String from, String to) {
this.testName =testName;
this.from =from;
this.to =to;
}
@Test
public void scenario()throws Exception{
/* Test Script */
}
@Parameters
public static Collection<Object[]> getData() throws ParserConfigurationException, SAXException, IOException {
XMLReader reader = new XMLReader("NewFile.xml");
return reader.readXML();
}
请提供您对此的意见。
【问题讨论】:
标签: java junit4 parameterized