I have a class
class A {
List<int> a;
A() {
this.a = [];
}
void add(int x) {
a.append(x)
}
List<int> display() {
return a;
}
}
This is a simple class I want to write in a TDD approach. my question is how do you write the test for the display()
since the add()
need to be called to make the test useful.
And it feels wrong to test the function it needs to rely on the other function which requires testing.
How to we handle this?