我的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测试
发布评论