想象我有一个方法:如何区分单元测试方法?
void Method(bool parameter){
if(parameter){
// first case
} else {
// second case
}
}
你首选的单元测试组织方法?
选项1:
void MethodTest(){
// test first case
// test second case
}
或
选项2:
void MethodTestFirstCase(){
// test first case
}
void MethodTestSecondCase(){
// test second case
}
+1为“一个在另一个的路上”。这通常是在单个测试中进行多重检查的理由。 – 2009-07-01 20:11:01