Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单元测试 #56

Open
ChelesteWang opened this issue Apr 17, 2022 · 5 comments
Open

单元测试 #56

ChelesteWang opened this issue Apr 17, 2022 · 5 comments

Comments

@ChelesteWang
Copy link
Owner

ChelesteWang commented Apr 17, 2022

为什么要做单元测试

如果你说我的业务部门不需要频繁上线,并且我有足够的人力来覆盖手工测试,那你可以不用单元测试
如果你说我不在意代码腐化,并且我也不做重构,那你可以不用单元测试
如果你说我不在意代码质量,好几个没有测试保护的 if-else 裸奔也不在话下,脑不好还做什么程序员,那你可以不用单元测试
如果你说我确有快速部署的需求,但我们不 care 质量问题,出回归问题就修,那你可以不用单元测试
除此之外,你就需要写单元测试。如果你想随时整理重构代码,那么你需要写单元测试;如果你想有自动化的测试套件来帮你快速验证提交的完整性,那么你需要写单元测试。

综上,我用以谈单元测试的「透镜」是什么呢?一言以蔽之,两点:反馈速度和自动化。

@ChelesteWang
Copy link
Owner Author

值得学习的blog

https://github.com/EthanLin-TWer/blog

@ChelesteWang
Copy link
Owner Author

ChelesteWang commented Apr 17, 2022

React 单元测试究竟在测试什么

  1. 组件状态
  2. 业务数据流
  3. 业务无瓜的工具函数(保证无副作用,100% 覆盖)

@ChelesteWang
Copy link
Owner Author

React 组件测试在测试什么

通过对内部 DOM 对象属性以及内容等,测试组件逻辑是否符合预期

@ChelesteWang
Copy link
Owner Author

通过组件库学习单元测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant