【发布时间】:2011-04-01 21:14:49
【问题描述】:
我正在使用 Selenium RC 和 JUnit 编写测试。如果@Test 失败,我想截屏,但我想使用从Test 类传递的特定截屏名称。
目前我有:
@Rule
public ScreenshotRule email = new ScreenshotRule();
@Test
public void testLogin() throws InterruptedException {
MyTest someTest = new MyTest(selenium);
someTest.someMethod (); // if anything assert fails in this method, i want to take a shot and call it a name which i will pull from the MyTest class.
}
这是Screenshot 类:
public class ScreenshotRule extends TestWatchman {
@Override
public void failed(Throwable e, FrameworkMethod method) {
System.out.println(method.getName() + " failed");
// At this point I wish to take a screenshot and call
}
}
那么如何将String arg 从MyTest 类传递给Screenshot 类?
【问题讨论】:
标签: java unit-testing junit junit4