0
背景接入领域
我有以下情况:
- 我的测试类实现
org.testng.ITest
- 他们都对一个
Helper
含信息目前的测试环境(例如被测设备)
例如:
com.company.appundertest.Helper h;
public class TestClass implements org.testng.ITest {
private String testName;
//Helper is initialized externally in Factory + DataProvider
//and passed to Constructor.
public TestClass(com.company.appundertest.Helper hh) {
this.h = hh;
//constructor sets the test-name dynamically
//to distinguish multiple parallel test runs.
this.testName = "some dynamic test name";
}
@Override
public String getTestName() {
return this.testName;
}
@Test
public void failingTest() {
//test that fails...
}
}
- 这些测试类是使用厂和并行数据提供者并行地执行。
- 在测试失败时,我需要访问失败测试类的助手实例中的变量。这些将用于在故障点识别环境(例如,在发生故障的设备上截屏)。
这个问题基本上可以归结为:
如何我将访问TestNG的测试类中的字段?
参考