不知道大家看过这两本书没有:《Pragmatic Unit Testing——In Java with JUnit》 和 《Pragmatic Unit Testing——In C# with NUnit》。内容是非常不错的。比如就启发你测试什么这个方面吧,提出了非常Pragmatic的几天建议:
Are the results right?
Are all the boundary conditions CORRECT?
Can you check inverse relationships?
Can you cross-check results using other means?
Can you force error conditions to happen?
Are performance characteristics within bounds?
Are the results right?
Are all the boundary conditions CORRECT?
Can you check inverse relationships?
Can you cross-check results using other means?
Can you force error conditions to happen?
Are performance characteristics within bounds?
这个合称为:Right-BICEP
还有关于帮助你发现边界条件的口诀CORRECT:
Conformance Does the value conform to an expected format?
Ordering Is the set of values ordered or unordered as appropriate?
Range Is the value within reasonable minimum and maximum values?
Reference Does the code reference anything external that isn't under direct control of the code itself?
Existence Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.)
Cardinality Are there exactly enough values?
Time (absolute and relative) Is everything happening in order? At the right time? In time?
Ordering Is the set of values ordered or unordered as appropriate?
Range Is the value within reasonable minimum and maximum values?
Reference Does the code reference anything external that isn't under direct control of the code itself?
Existence Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.)
Cardinality Are there exactly enough values?
Time (absolute and relative) Is everything happening in order? At the right time? In time?
但是这真的是两本书吗?其实并不是。两本书相似度有多少呢?我觉得至少有95%。把NUnit版本的转换为JUnit的大致只需要:
1、把C#替换为Java
2、把NUnit替换为JUnit
3、把大写开头的方法名变成小写开头的
4、把使用Attribute的内容换成类继承
5。。。
基本上就是几条简单的原则就把一本书变成了另外一本了。
这就说明了一个问题了。技术的同质化已经非常非常严重了。正如书中所说:
But while the examples are in Java, using the JUnit framework,the concepts remain the same whether you are writing in C++, Fortran, Ruby, Smalltalk, or VisualBasic. Testing frameworks similar to JUnit exist for over 60 different languages; these various frameworks can be downloaded for free.
类似的,整个J2EE和.NET的开发思路也在融合。对于市面上越来越喧嚣的技术尘埃,我已经觉得麻木了。开始怀念书橱中已经开始上灰的计算机教材了。怀念第一次看Andrew S.Tanenbaum 的书的时候的激动感觉。。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架