mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-07 01:23:56 -05:00
Started verification tests
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user