In affected IT.java's, replace inheritance flags with polymorphism
Opened this issue · 0 comments
sming commented
or in more mechanical terms:
replace:
flags in IT.java base classes like protected boolean subclassHasFeatureX = true;
+
tests for that flag in the base class e.g. assumeTrue("Test huge row key write", hugeRowKey)
+
setting of said flag in concrete subclasses e.g. this.subclassHasFeatureX = false;
with:
- remove the flag
- keep the test in the base class but move the body of the test to a virtual method e.g.
@Test
public void FeatureXTest() {
FeatureXTestImpl();
}
public void FeatureXTestImpl() {
// test guts
}
- in subclasses that do not support FeatureX, override
FeatureTestImpl
to be a no-op:
@Override
public void FeatureXTestImpl() { /* no-op */ }
et voila
no more flags or run time exceptions if the developer forgets that the subclass doesn't support feature X.
See the original comment here.