当前位置:网站首页>Advanced skills of testers: a guide to the application of unit test reports
Advanced skills of testers: a guide to the application of unit test reports
2022-07-01 23:02:00 【Xiaowu knock code】
Why unit testing is needed
From a product perspective , Routine function test 、 System tests are conducted based on the local or global functions of the product , It can be well combined with the needs of users , But there is a lack of product development details ( Especially the understanding of code details ).
From the tester's point of view , Functional test, system test and other performance tests require testers to have a high ability to understand the global characteristics , As long as testers can master oneortwo automated test frameworks, they can basically carry out functions 、 Performance automated testing , But research and development with the help of testing framework reduces testers' mastery of code 、 Understanding requirements .
From a developer perspective , User requirements are often not specific 、 comprehensive , Therefore, there are limitations in converting user requirements into development documents or writing development code for a certain function ( That is what we often say bug).
therefore , Writing unit tests can help testers better understand code details 、 Improve code development capability , It can also help developers identify possible problems in the code in advance bug, Improve the fault tolerance of code .
How to make unit test report
Good unit test reports can help testers better analyze 、 Digging for hidden problems . that , How to make a unit test report , From which dimensions ? Here we mainly think about this problem from the perspective of testers .
First , We need to present the number of our test cases and test results in the report (pass perhaps fail), And error details .
secondly , Starting from the characteristics of unit test itself , We need to be able to show the branch for unit code in the report 、 Coverage of unit methods, etc , Better help us sort out and test the excellence of case design .
Here it is , We use surefire-report Count the number of test cases and test results , Use jacoco The coverage rate of unit measurement is calculated ( notes : The default test case execution method in this article is mvn test).
How to configure
surefire-report To configure
Configuration method : To configure maven-surefire-plugin plug-in unit ,maven-surefire-plugin yes maven default test actuator , The configuration method is shown in the figure below :
Above picture testFailureIgnore It means to ignore the errors in the unit test and continue to build ,/*Test.java: Indicates that all the names under any subdirectory are named with Test At the end of the Java class ,/Test*.java: It means that all naming under any subdirectory will not be executed Test At the beginning Java class .
Execution method : Use mvn test surefire-report:report that will do , Will be generated in /target/site/surefire-report.html Test report document .
As shown in the figure below :
Tests Displays the total number of use cases ;
Errors It refers to the situation that the procedure does not take into account , For example, exception failed to catch ;
Failure It refers to the difference between the expected result and the result of the actual operation unit , It often appears in assertions ;
Skipped Indicates the number of test cases skipped ;
Success Rate Indicates the success rate of the use case (= Number of successful use cases / Total number of use cases );
Time Show total time ;
Package List Show detailed package Next use case execution result .
Configuration method : To configure jacoco-maven-plugin plug-in unit , The configuration method is shown in the figure below ,phase Represents the life cycle phase of the plug-in operation .
Execution method :mvn test Execution can be . Will be in /target/site/jacoco/ Generate the total coverage report under the directory index.html And different package Unit test coverage report for …/xxx/index.html. Besides, there are csv and xml Unit test coverage report in .
As shown in the above figure, there is a package Unit test coverage report for :
The red progress bar table does not cover ;
A green progress bar indicates that ;
Cov Is the overall coverage ;
Missed Instructions Indicates code coverage ;
Missed Branches Indicates the logical branch coverage ;
Missed Cxty Indicates the number of judgments executed ;
Missed Lines Represents the number of lines of code ;
Methods Indicates the number of methods .
How to use unit test reports
thus , We talked about the importance of unit tests and how to set up and view unit test reports . Now let's talk about how to use unit test reports .
In this article, we describe two unit test reports , One is to facilitate testers to count the number of unit test cases and analyze the results of case execution from the perspective of testers surefire-report The report , The other is to help testers and developers analyze the code coverage of unit test cases jacoco The report .
about surefire-report For reporting purposes , We are mainly used to count the number of use cases and judge whether the use case design is reasonable through the use case execution results 、 Is there a problem with the test environment , Can be similar to something closer to the code layer “ A functional test ” The report .
about jacoco Unit test coverage report , We can judge whether the test case design is missing by unit test coverage , So as to complete the missing test cases . The following figure shows a Package Unit test coverage report of a method in a class .
As shown in the figure above , Green diamonds mean full coverage , Yellow diamonds indicate partial coverage , A red diamond means there is no cover .
From the above test report, we can see the lack of unit test cases covering the red part , So it can be redesigned 、 Complete the test cases corresponding to the red branch .
Summary
For most testers , There are few opportunities to contact unit testing at work . however , From the perspective of career development path and personal ability improvement , Learning unit testing can not only improve the business ability of testers , Understanding of the code , It can also improve some “ viability ” Well , It is said that “ Many hands make light work ” It is so .
Finally, thank everyone who reads my article carefully , The following online link is also a very comprehensive one that I spent a few days sorting out , I hope it can also help you in need !
These materials , For those who want to change careers 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful ……
If you don't want to grow up alone , Unable to find the information of the system , The problem is not helped , If you insist on giving up after a few days , You can click the small card below to join our group , We can discuss and exchange , There will be various software testing materials and technical exchanges .
Click the small card at the end of the document to receive it |
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
Self study recommendation B Stop video :
Zero basis transition software testing :25 Days from zero basis to software testing post , I finished today , Employment tomorrow .【 Include features / Interface / automation /python automated testing / performance / Test Development 】
Advanced automation testing :2022B The first station is super detailed python Practical course of automated software testing , Prepare for the golden, silver and four job hopping season , After advanced learning, it soared 20K
边栏推荐
- SAP 智能机器人流程自动化(iRPA)解决方案分享
- 转载csdn文章操作
- cvpr2022 human pose estiamtion
- Electron学习(三)之简单交互操作
- 多图预警~ 华为 ECS 与 阿里云 ECS 对比实战
- 【Kotlin 第三方 】coil koltin协程图片加载库Coil类似Glide的图片加载第三方
- 使用3DMax制作一个象棋棋子
- Vsphere+ and vsan+ are coming! VMware hybrid cloud focus: native, fast migration, mixed load
- Appium automation test foundation - appium installation (I)
- 数字化转型道阻且长,如何迈好关键的第一步
猜你喜欢
[untitled]
SAP UI5 应用开发教程之一百零四 - SAP UI5 表格控件的支持复选(Multi-Select)以及如何用代码一次选中多个表格行项目
使用3DMax制作一个象棋棋子
死锁的处理策略—预防死锁、避免死锁、检测和解除死锁
Fiori 应用通过 Adaptation Project 的增强方式分享
tcpdump命令使用详解
[target tracking] | single target tracking indicator
使用 EMQX Cloud 实现物联网设备一机一密验证
Fiori applications are shared through the enhancement of adaptation project
思科--WAN 的概念考试外部工具
随机推荐
"Trust machine" empowers development
Hide the creation and use of users
Data enhancement of semi supervised learning
Contents of other parts of the map
Business visualization - make your flowchart'run'up
[literacy] deep / shallow, local / global features in machine learning image processing
Using emqx cloud to realize one machine one secret verification of IOT devices
Appium自动化测试基础 — 补充:Desired Capabilities参数介绍
Mysql 5.7 实现 rank 排名
internal field separator
cvpr2022 human pose estiamtion
阿洛迷茫后的思考
Cisco test -- the concept and configuration test of routing
激发新动能 多地发力数字经济
软件测试之「 性能测试」总结,新手上路必会知识点
General use of qstringlist
多图预警~ 华为 ECS 与 阿里云 ECS 对比实战
使用 EMQX Cloud 实现物联网设备一机一密验证
A few minutes before work, I found out V-model and The difference between sync
[daily training] 326 Power of 3