当前位置:网站首页>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~
参考资料
边栏推荐
- 浅谈Numpy中的shape、reshape函数的区别
- SQLi-LABS Page-2 (Adv Injections)
- 定投的基金
- C语言中的文件是什么?
- Leetcode 93 IP addresses
- PMP daily practice | didn't lost a 8.9 (including agile + multi-select)
- Word怎么设置图片衬于文字下方?两种方法教你设置Word图片衬于文字下方
- MySQL跨表、多表更新SQL语句总结
- 蔚来杯2022牛客暑期多校训练营7 CFGJ
- Synchronization lock synchronized traces the source
猜你喜欢
QGIS编译SIP的问题
Word文档怎么输入无穷大符号∞
在VMware上安装win虚拟机
SQL语句及索引的优化
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
Word怎么制作双面席卡?使用Word制作双面席卡方法
Puyuan Jingdian turned losses into profits in the first half of the year, and high-end products continued to develop!Are you optimistic about "Huawei" in the instrument industry?
人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备
别叫我玩,我要考PMP:考PMP选择机构需要了解的那些事儿
Lyapp exponents and bifurcation diagrams for fractional chaotic systems
随机推荐
Byte side: Can TCP and UDP use the same port?
什么是IDE(集成开发环境)?
【泛型编程】模板全详解
Bean生命周期
Hessian Matrix 海森矩阵
浅谈Numpy中的shape、reshape函数的区别
RHEL7系统修复rm -rf /boot /etc/fstab
在VMware上安装win虚拟机
FS4066耐高压1到4节内置MOS的锂电池充电管理芯片
技术分享 | 接口自动化测试如何处理 Header cookie
Daily practice of PMP | Do not get lost in the exam -8.8 (including agility + multiple choice)
2021(ICPC)亚洲区域赛昆明站(CGHIJLM)
Deceptive Dice(期望计算)
C语言中的文件是什么?
宝塔实测-搭建LightPicture开源图床系统
The round functions in the np, ceil function and floor function
微软Excel表格点击单元格行和列都显示颜色怎么弄?聚光灯效果设置
LoRa无线技术在物联网应用市场的概况和发展
场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon
角度和弧度的相互换算