如何使用 TestNg 记录测试历史? [英] How does one record test history with TestNg?

查看:40
本文介绍了如何使用 TestNg 记录测试历史?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组从 Intellij IDEA 运行的基于 Java 的 api 测试.由于每次测试运行中的相同原因,某些测试通常会失败.一些测试失败的频率较低.我想至少运行所有测试一百次,以找出哪些测试失败以及每个失败测试失败的独特原因是什么.

I have a set of java based api tests which I run from Intellij IDEA. Some of the tests generally fail due to the same reason in each test run. Some tests fail less often. I want to run all the tests at least a hundred times to find out which tests failed and what are the unique reasons for the failure of each failed test.

这是我想为自己制作的报告示例.每个失败的测试都有一行.每个冒号前的文本实际上是列名.

Here is an example of the report I want to make for myself. There is one row for each failing test. The text before each colon is actually the column name.

failingTest:myTest,failureReason:预期为 200,但得到 304,timesOccurred:25/100,stackTrace:text.

failingTest: myTest, failureReason: Expected 200 but got 304, timesOccurred: 25/100, stackTrace: text.

failingTest: myTest, failureReason: 404 not found, timesOccurred: 5/100, stackTrace: text.

failingTest: myTest, failureReason: 404 not found, timesOccurred: 5/100, stackTrace: text.

所以,从上面我们看到myTest"总共失败了 30/100 次.生成此类报告的最简单方法是什么?

So, from the above we see that "myTest" failed a total of 30/100 times. What is the easiest way to generate such a report ?

谢谢.

推荐答案

最简单的方法是通过实现由支持的 org.testng.IReporter 来构建自定义报告器一个数据库,您可以在其中添加测试结果.

The easiest way of doing this would be for you to build a custom reporter by implementing org.testng.IReporter which is backed by a database, within which you add the test results.

如果特定方法的测试结果已经存在,则根据每个唯一失败原因的测试结果更新其执行计数以及通过/失败计数.

If the test result for a particular method already exists, then update its execution count and also its pass/fail count based on the test results for every unique failure reason.

这篇关于如何使用 TestNg 记录测试历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆