Reputation: 345
Skipped test are not displayed on extent reports.
I am using dependsonmethods
and as per method extent report should display test case with log skip.
But it print skip log on previous test case.
@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();
}
Please check image image of test execution.
Image of console 5 test case,failed 1, skipped 1
Skipped test case log printed on previous test case logs
Skipped test case is not printing in extent report.
Upvotes: 0
Views: 2498
Reputation: 65
I have also faced this issue and code below worked for me. Define the testListener like this and then call this testListener class in your Baseclass by using @listeners(TestListeners.class) before Baseclass starts.
Note : I have used Spark Extentreport
public class TestListeners implements ITestListener {
@override public void onTestSkipped(ITestResult result) {
Baseclass.extenttest = Baseclass.extent.createTest(result.getMethod().getDescription()).assignCategory("SkipedTest");
Baseclass.extenttest .log(Status.SKIP, result.getThrowable());
Baseclass.extenttest .log(Status.SKIP, result.getMethod().getDescription());
Baseclass.extenttest .log(Status.SKIP, MarkupHelper.createLabel(result.getName(), ExtentColor.YELLOW));
Baseclass.extent.flush();
} }
In your test class define @Test like below
@Test(description = "Test Case name", dependsOnMethods = { "Name of method on which it depends" })
Upvotes: 0
Reputation: 11
I have a similar question but approach the issue differently. Have an after method that works great when I explictly tell it test.pass() or test.fail(), but I am struggling to have the extent reporter catch and document a skipped test. TestNG is reporting that full tests are being skipped, want to see that in the extent out put.
@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());
}
}
An example of a single validation:
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);
}
Upvotes: 1