本文介绍了检索@Test描述表testNG测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的testNG测试具有以下格式:

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{
}

是否有一种方法可以实现一些内容,该内容可以读取所有测试说明,并由此生成测试文档.我试图以某种方式将ITestNGMethod getDescription()包含到afterInvocation(IInvokedMethod method, ITestResult testResult)中,因此在运行每种方法之后,都将返回说明,但没有成功.有人尝试过类似的东西吗?

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?

推荐答案

最简单的方法是使用ITestResult.

The simplest way is by using ITestResult.

    @Override
    public void afterInvocation(IInvokedMethod arg, ITestResult arg1) { 
      System.out.println(arg.getTestMethod().getMethodName());
      System.out.println(arg1.getMethod().getDescription());
    }

第二个sysout将返回调用的测试方法的(字符串)描述.

The second sysout will return a (String) description of the invoked test method.

这篇关于检索@Test描述表testNG测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 12:28