@@ -83,6 +83,7 @@ public void verifyFakeCommandNotScheduledBeforeTest() {
8383 @ Test
8484 @ Order (2 )
8585 public void verifyFakeCommandNotScheduledAfterTest (CommandTester commandTester ) {
86+ assertThat (commandTester ).isNotNull ();
8687 CommandScheduler commandScheduler = CommandScheduler .getInstance ();
8788 assertWithMessage ("Expect all commands to have been cancelled" )
8889 .that (commandScheduler .isScheduled (FAKE_COMMAND ))
@@ -223,44 +224,43 @@ public boolean isFinished() {
223224 }
224225
225226 private static class PeriodicElapsedCommand extends Command {
226- private boolean finished = false ;
227- private boolean ex1Exists ;
228- private boolean ex2Exists ;
227+ private boolean completed ;
228+ private int executeCount ;
229229 private double ex1Time ;
230230 private double ex2Time ;
231231
232232 @ Override
233233 public void initialize () {
234- ex1Exists = false ;
235- ex2Exists = false ;
236- finished = false ;
234+ executeCount = 0 ;
235+ completed = false ;
237236 }
238237
239238 @ Override
240239 public void execute () {
241- if (!ex1Exists ) {
242- ex1Time = Timer .getFPGATimestamp ();
243- ex1Exists = true ;
240+ executeCount ++;
241+ assertWithMessage ("execute() must only be called twice!" ).that (executeCount ).isLessThan (3 );
242+
243+ double now = Timer .getFPGATimestamp ();
244+ if (executeCount == 1 ) {
245+ ex1Time = now ;
244246 } else {
245- assertWithMessage ("execute() must only be called twice!" ).that (ex2Exists ).isFalse ();
246- ex2Time = Timer .getFPGATimestamp ();
247- ex2Exists = true ;
247+ ex2Time = now ;
248248 }
249249 }
250250
251251 @ Override
252252 public boolean isFinished () {
253- return ex2Exists ;
253+ return executeCount == 2 ;
254254 }
255255
256256 @ Override
257257 public void end (boolean interrupted ) {
258- finished = !interrupted ;
258+ completed = !interrupted ;
259259 }
260260
261261 public double executionTime () {
262262 assertWithMessage ("This command must run to completion before getting the execution time!" )
263- .that (finished )
263+ .that (completed )
264264 .isTrue ();
265265 return ex2Time - ex1Time ;
266266 }
0 commit comments