Inadequate Assertion
Definition:
Every update to the execution state must eventually be verified in the assertions. In principle, assertions should verify the correctness of all updates to the object/program state, otherwise the strength of the test oracles is considered not enough to guard the program against faults.
Code Example:
public class ClassUnderTest{
private int data1;
private int data2;
public int getData1() { return data1;}
public int getData2() { return data2;}
public void method1(int flag){
if(flag>0){
this.data2 = 2; //define data2
}
this.data1 = 4; //define data1
public class ClassUnderTest extends TestCase{
public void testMethod1(){
ClassUnderTest cut = new ClassUnderTest;
int testInput = 1;
cut.method1(testInput);
assertTrue(cut.getData1()==4); // Is this assertion adequate enough?
References:
Quality attributes
- Code Example
- Cause and Effect
- Frequency
- Refactoring