Started verification tests

This commit is contained in:
2022-12-04 23:27:25 -05:00
parent 62a8589364
commit 7a3f2214f8
20 changed files with 721 additions and 7 deletions

View File

@@ -0,0 +1,42 @@
package com.mattrixwv.project_euler.problems;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.atMostOnce;
import static org.mockito.Mockito.verify;
import org.mockito.Spy;
import com.mattrixwv.Stopwatch;
public abstract class BaseTest{
@Spy
protected Stopwatch timer;
public abstract void testDescription();
public abstract void testSolve();
protected void verifyProblem(Problem problem){
//Verify solved was set
assertTrue(problem.getSolved());
//Verify timer function were called
verify(timer, atLeastOnce()).start();
verify(timer, atLeastOnce()).stop();
}
protected void verifyProblemSecondRun(Problem problem){
problem.solve();
//Verify solved is still set
assertTrue(problem.getSolved());
//Verify timer functions were not called again
verify(timer, atMostOnce()).start();
verify(timer, atMostOnce()).stop();
}
public void testReset(){
//Verify timer was reset
verify(timer, atLeastOnce()).reset();
}
}