跳过的测试未显示在范围报告中。
我正在使用dependsonmethods
,根据方法范围报告应显示带有日志跳过的测试用例。但它会在先前的测试用例上打印跳过日志。
@Test(priority = 12)
void UndoRedo() {
undoRedoCase.UndoRedoTest();
}
@Test(priority = 13)
void LockUnlock() {
lockUnlockElement.LockUnlockCase();
}
@Test(priority = 14)
void FrameLayer() {
layerFrame.FrameLayerCase();
}
@Test(priority = 15)
void AddImage() {
addimage.AddImageCase();
}
@Test(priority = 16,dependsOnMethods = {"AddImage"})
void EraseImage() {
imageErase.ImageEraseCase();
}
请检查测试执行的图像。
跳过的测试用例不在范围报告中打印。
我有一个类似的问题,但是对问题的处理方式有所不同。当我明确地告诉它test.pass()或test.fail()时,有一个after方法可以很好地工作,但是我正在努力使记者无法捕获并记录跳过的测试。 TestNG报告正在跳过完整的测试,希望在输出范围内看到它。
@AfterMethod
public void getResult(ITestResult result) {
if(result.getStatus() == ITestResult.FAILURE) {
test.log(Status.FAIL, MarkupHelper.createLabel(result.getName()+" FAILED ", ExtentColor.RED));
test.fail(result.getThrowable());
}
else if(result.getStatus() == ITestResult.SUCCESS) {
test.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" PASSED ", ExtentColor.GREEN));
}
else if(result.getStatus() == ITestResult.SKIP) {
test.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" SKIPPED ", ExtentColor.RED));
}
else {
test.log(Status.SKIP, MarkupHelper.createLabel(result.getName()+" SKIPPED ", ExtentColor.ORANGE));
test.skip(result.getThrowable());
}
}
单个验证的示例:
try {
softAssert.assertEquals(plain1, plain2);
test.pass("PASS: Field is edited");
} catch (AssertionError e) {
test.fail("FAIL: Field is NOT edited");
test.fail(e);
throw (e);
}