我可以得到由maven执行的测试用例的总数吗? [英] Can I get the total number of test cases executed by maven?

查看:143
本文介绍了我可以得到由maven执行的测试用例的总数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目,上面有几个子项目.每个子项目都有其自己的测试用例,并且它们都工作正常.我想知道在父项目上执行的测试用例的数量.

I have a maven project on which there are several sub-projects. Each sub-project has its own test cases and all of them are working fine. I want to know the number of test cases being executed on the parent project.

无论如何,我是否可以获得执行的所有测试用例的详细信息?甚至测试用例的数量也很好.

Is there anyway I can get the details of all the test cases executed? Even the number of test cases is also fine.

请分享您的宝贵意见.

推荐答案

如果要一次性完成,可以先将maven构建输出到日志文件:

If you want to do it as a one off you could first output the maven build to a log file:

mvn clean verify > maven_build.out

然后,您可以运行一个bash衬板以总结运行的测试数量:

Then, you can run a bash one liner to sum up the number of tests run:

 echo $(( $(cat maven_build.out | grep "Tests run" | grep -v "Time elapsed" | cut -d , -f 1 | cut -d " " -f 3 | tr "\n" "+") 0))

这将从日志中提取出每个摘要的所有测试运行"(重复进行),其旁边的数字,并将其相加.

This will extract all the 'Tests run' out of the log for each summary (as it is repeated), the number next to it, and sum it.

您需要Unix或cygwin

You'll need unix or cygwin

这篇关于我可以得到由maven执行的测试用例的总数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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