我通常会尽量避免重复并遵守 DRY 原则。但是,我想知道这样的案例:
public class Feature {
final static String FEATURE_LABEL = "blah";
public void doSomething() { ... }
...
}
public class FeatureTest {
...
@Test
public void doSomethingShouldMakeSomethingHappen() {
assertEquals(Feature.FEATURE_LABEL,
feature.getSomethingHappens().getLabel());
}
如果要求标签为“blah”并且有人将 FEATURE_LABEL 更改为“bleh”,则即使不再满足要求,测试也会通过。这是违反 DRY 的有效场所吗?