如何使用 Angular 8 以后的 SCURI 自动编写单元测试用例 [英] How to write unit test cases automatically using SCURI in angular 8 onwards

查看:27
本文介绍了如何使用 Angular 8 以后的 SCURI 自动编写单元测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个名为 SCURI 的 npm 包,可用于自动为 .ts 文件编写单元测试用例,覆盖率超过 70%.

There is an npm package named SCURI which can be utilized to write unit test cases for .ts files automatically to cover more than 70% coverage .

只需要安装这个包,完成后,创建 autoSpy.ts 文件来定义如何模拟/创建依赖项的存根.

Just need to install this package and once done, create autoSpy.ts file to define how to mock/create stubs for dependencies.

推荐答案

正如文档中所说,它

自动化 Angular 的单元测试样板

Automates unit test boilerplate for Angular

因此,减少了简单的事情,即规范文件创建、导入、构造函数实例化、方法调用、基本 AAA 模式、一些模拟等.

so, reduces the no-brainers, i.e spec file creation, imports, constructor instantiations, method invocations, basic AAA pattern, some mocking etc.

所有(高级)逻辑设计和检查你最好自己做.

All the (advanced) logical design and checks you better do yourself.

这篇关于如何使用 Angular 8 以后的 SCURI 自动编写单元测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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