简体   繁体   English

如何在关键字驱动的框架中实施TestNg报告

[英]How to implement TestNg reporting in keyword driven framework

I am trying to implement TestNG for reporting purpose in my keyword driven framework (Java). 我正在尝试在关键字驱动的框架(Java)中实现TestNG以进行报告。 I need to publish execution time of each test cases (and step), pass/fail status of each test cases(and step) in my reports. 我需要在报告中发布每个测试用例(和步骤)的执行时间,每个测试用例(和步骤)的通过/失败状态。 TestNG does it automatically if there are separate methods for each test case. 如果每个测试用例都有单独的方法,则TestNG会自动执行此操作。 The problem that I'm facing is I'm running a loop for each test case, in that loop a method gets called to execute that particular test case. 我面临的问题是我为每个测试用例运行一个循环,在该循环中,调用了一种方法来执行该特定测试用例。 Now, in the called test case method, again a method gets called for each test step. 现在,在被调用的测试用例方法中,每个测试步骤都会再次调用一个方法。 How can I design my framework so that TestNG treats each test case/step as a new method and furnishes the execution time and pass/fail status of each test case/step. 如何设计框架,以便TestNG将每个测试用例/步骤视为一种新方法,并提供每个测试用例/步骤的执行时间和通过/失败状态。 I'm also open to any other suggestions by which I can implement the reporting module in my keyword-driven framework 我也乐于接受任何其他建议,通过这些建议,我可以在关键字驱动的框架中实施报告模块

Yeah, its doable with some effort. 是的,通过一些努力它是可行的。 You can create a custom TestNG reporter, similar to how I did it in this project , and by doing that you can add a new column the test report, just as I added the "test name" column, and then you can put together the data you need and place it in that cell on the test row. 您可以创建一个自定义的TestNG报告程序, 类似于我在该项目中所做的操作,这样做可以在测试报告中添加一个新列,就像我添加“测试名称”列一样,然后可以将您需要的数据并将其放在测试行的该单元格中。

To store the timings, per method call, I would use Stopwatch from Apache commons-lang3 . 为了存储时间,对于每个方法调用,我将使用Apache commons-lang3中的Stopwatch。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM