我是新手,如果我问愚蠢的问题,请原谅。
当“@BeforeTest”失败时面临问题,“@Test”通过“@Factory”运行。理想情况下,当“@BeforeTest”失败时,应该跳过测试,但这里没有这样做,@Test 正在执行。
请阐明这个问题或让我知道我缺少什么。
测试NG XML:
<test name="FactoryTest">
<parameter name="callSSO" value="com.acc.Test1.callSSO"/>
<groups>
<run>
<include name="@mode@"/>
</run>
</groups>
<classes>
<class name="com.acc.FactoryTest"/>
</classes>
</test>
测试NG类:
public class ADFSTest {
public ADFSTest(Object testData) {
this.testData = (ArrayList) testData;
}
@Factory
public Object[] createTestInstances() {
Object[] testInstances = null;
try {
finalList = getTestData(); **<<<<---- GETS TEST INPUT FROM FILE (no complex stuff)**
testInstances = new Object[finalList.size()];
for (int i = 0; i < finalList.size(); i++)
testInstances[i] = new ADFSTest(finalList.get(i));
} catch (Exception e) {
e.printStackTrace();
}
return testInstances;
}
@BeforeTest(groups = { "group1" })
public void setUp() throws Exception {
boolean isADFSConfigComplete = false;
try {
System.out.println("*** IN SETUP ***");
isADFSConfigComplete = adfsConfig.setUp(); **<<<<------- THROWS SOME EXPECTION IF SOME THINGS GOES WRONG**
}
} catch (Exception e1) {
e1.printStackTrace();
}
@AfterTest(groups = { "group1" })
public void cleanUp() throws Exception {
try {
System.out.println("*** IN CLEANUP ***");
}
} catch (Exception e) {
e.printStackTrace();*
}
@Parameters({ "com.acc.Test1.callSSO" })
@Test(groups = { "group1" })
public void callSSO(String testName1) throws Exception {
String testName = testData.get(0).toString();
String initOp = testData.get(1).toString();
String userState = testData.get(2).toString();
String authScheme = testData.get(3).toString();
String user = testData.get(4).toString();
System.out.println("------------>> TestName is " + testName);
System.out.println("------------>> UserState is " + userState);
System.out.println("------------>> User is " + user);
if(user.equals("Fred")
assert true;
else
assert false;
}
}
正在使用的TestNG jar: testng-5.10-jdk15.jar