Open PiroX4256 opened 2 years ago
Some classes have been committed, I created only two tests now because I have nothing else to test (seems to me, since almost all the other methods are simple getters, setters, and constructors), am I missing something and should test in a different way?
as said, don't test set/get.
by the way... I think the underlying logic is not enough clear. for 1 line of code, 3 of test to verify that what we wrote is correct:
If You write (your code):
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Dining_room that)) return false;
return getStudents() == that.getStudents() && getColor() == that.getColor();
}
@Override
public int hashCode() {
return Objects.hash(getColor());
}
public void putStudent(){
this.students++;
}
public void removeStudent(){
this.students--;
}
yuo should have at least 8 methods, to test success and failure addiung, removing, comparing and so on.. and possibly many more.
let see another example:
**int Factorial( int number ) {
return number <= 1 ? number : Factorial( number - 1 ) * number;
}**
we need 3 different tests to get a decent coverage AND to discover a bug...
public void negTest()
{
Calculator c = new Calculator();
assertTrue( c.Factorial(-1) > 0 );
}
@Test
public void TestOf10()
{
Calculator c = new Calculator();
assertTrue( c.Factorial(10) == 3628800 );
}
@Test
public void TestOf18()
{
Calculator c = new Calculator();
assertTrue( c.Factorial(18) > 0 );
}
}
for any need, feel free to write.
Please start committing code and testing all the classes.