当前位置:网站首页>unit test
unit test
2022-08-09 23:13:00 【51CTO】
单元测试是什么
单元测试是一种软件测试,其测试软件的各个单元或组件.The purpose is to verify that each unit of software code executes as expected.单元测试由开发人员在应用程序的开发(编码阶段)中完成.单元测试隔离一段代码并验证其正确性.A unit may be单个功能,方法,过程,模块或对象.
Why do unit tests
- 在开发阶段,Unit tests can help find and fix earlierBUG,并节省成本
- 它有助于开发人员了解代码库,and enable them to make changes quickly
- Good unit tests are the equivalent of project documentation
- 单元测试有助于代码重用,Migrate both our code and tests to the new project.调整代码,直到测试再次运行.
单元测试的好处
- 通过单元测试,Developers can see what functionality is provided,对单元测试
API
有基本了解 - 单元测试允许程序员在以后重构代码,并确保模块仍然正常工作(即回归测试).该过程是针对所有功能和方法编写测试用例,以便每当更改导致故障时,都可以快速识别并修复该故障.
- 由于单元测试的模块化性质,我们可以测试项目的各个部分,而无需等待其他部分完成.
The downside of unit testing
- Unit tests cannot catch every bug in a program.即使在最简单的程序中,It's also not possible to evaluate each unit test execution path.
- The essence of unit testing is to focus on the unit of code.因此,It doesn't catch integration-tested errors and broader system-level errors.
推荐:Unit testing is used in conjunction with other testing techniques
VUEUse unit tests in the project
我们使用 Vue-Test-Utils这个Vue.js
官方的单元测试实用工具库,来编写VUE
Unit tests in the application.
安装
这里,We have passed by defaultVUE
The scaffolding generated the project,then we integrateunit-jest
插件就可以了.
Write simple test cases
单元测试的文件:
Unit test components:
此时,Just execute the following command line:
这个时候,You can see the test case running on the console~
参考资料
边栏推荐
- QGIS编译SIP的问题
- 小黑leetcode之旅:94. 二叉树的中序遍历(补充Morris 中序遍历)
- PMP daily practice | didn't lost a 8.9 (including agile + multi-select)
- STC8H开发(十五): GPIO驱动Ci24R1无线模块
- 筑牢安全防线 鹤壁经济技术开发区开展安全生产培训
- 几种绘制时间线图的方法
- poj 3070 Fibonacci(简单矩阵连乘)
- Use convert_to_tensor in Tensorflow to specify the type of data
- Lyapp exponents and bifurcation diagrams for fractional chaotic systems
- hdu 1503 Advanced Fruits(最长公共子序列的应用)
猜你喜欢
消防安全培训|“蓝朋友”,开课了!
简单问题窥见数学
PMP daily practice | didn't lost a 8.9 (including agile + multi-select)
PMP每日一练 | 考试不迷路-8.9(包含敏捷+多选)
STC8H开发(十五): GPIO驱动Ci24R1无线模块
Skywalking系列学习之Trace Profiling源码分析
cadence中复制一部分PCB到另一个PCB中去
Problems with compiling SIP with QGIS
4D Summary: 38 Knowledge Points of Distributed Systems
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
随机推荐
单元测试
LeetCode26: remove duplicates in sorted array
MySQL:错误1153(08S01):得到的数据包大于“ max_allowed_packet”字节
Sudoku | Backtrack-7
ACM MM 2022 | Cloud2Sketch: 长空云作画,AI笔生花
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
Byte side: Can TCP and UDP use the same port?
leetcode: the Kth largest element in the array
2021(ICPC)亚洲区域赛昆明站(CGHIJLM)
STC8H Development (15): GPIO Drives Ci24R1 Wireless Module
Lyapp exponents and bifurcation diagrams for fractional chaotic systems
fixed investment fund
PMP每日一练 | 考试不迷路-8.9(包含敏捷+多选)
【Efficient Tools】Remote Control Software ToDesk (Favorites)
LoRa无线技术在物联网应用市场的概况和发展
cadence中复制一部分PCB到另一个PCB中去
UE4_定序器控制蓝图对象
Tensorflow中placeholder函数的用法
np中的round函数,ceil函数与floor函数