检索@Test描述表testNG测试

编程入门 行业动态 更新时间:2024-10-12 10:23:28
本文介绍了检索@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测试

本文发布于:2023-11-06 08:26:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563187.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   Test   testNG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!