【发布时间】:2014-12-09 17:02:11
【问题描述】:
我有两门课
public abstract class BaseClass
{
public string PropertyA {get; set;}
public virtual object CopyProperties(BaseClass other)
{
other.PropertyA = this.PropertyA;
}
}
以及继承自它的类
public class ChildClass : BaseClass
{
public string PropertyB {get; set;}
public virtual object CopyProperties(BaseClass other)
{
other.PropertyB = this.PropertyB;
base.CopyProperties(other);
}
}
我自然对如此复杂的逻辑进行了单元测试!
我有两个测试:
Ensure_calling_CloneProperties_copies_PropertyA() Ensure_calling_CloneProperties_copies_PropertyB()
我想知道下面的测试是否也需要
Ensure_calling_CloneProperties_on_ChildClass_calls_base()
我个人的看法是,我们应该在 ChildClass 上测试 CloneProperties 的行为,我们需要验证当我们调用 clone PropertyA 和 PropertyB 时都被正确复制——我们不需要(或不想)知道这是如何实现的.然而一位同事不同意。
鉴于敏捷和 TDD 最佳实践,我是否还应该创建第三个测试?
【问题讨论】:
标签: unit-testing tdd code-coverage agile