Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving @Test description form testNG tests

I have the following format on my testNG tests:

@Test(alwaysRun = true, dependsOnMethods = "testStep_1", description = "Enter the names, and verify that they are appearing correctly ")
public void testStep_2() throws Exception{
}

Is there a way to implement something that could read all test descriptions, and by that generating a test documentation. I tried to somehow include ITestNGMethod getDescription() to a afterInvocation(IInvokedMethod method, ITestResult testResult) so after each method is run, the description is returned, but with no success. Has anyone tried something similar?

like image 621
gandalf_the_cool Avatar asked May 26 '14 13:05

gandalf_the_cool


Video Answer


1 Answers

We tried something similar. Below is the method that print the testng test name and test description for each method.

@BeforeMethod
public void beforeMethod(Method method) {
    Test test = method.getAnnotation(Test.class);
    System.out.println("Test name is " + test.testName());
    System.out.println("Test description is " + test.description());
}
like image 115
Manu Avatar answered Nov 15 '22 13:11

Manu