不知道大家看過這兩本書沒有:《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 的書的時候的激動感覺。。。
浙公網安備 33010602011771號