This repository was archived by the owner on Sep 14, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Robot2018/test/org/usfirst/frc/team199/Robot2018 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import static org .mockito .Mockito .verify ;
66import static org .mockito .Mockito .when ;
77
8+ import org .junit .jupiter .api .BeforeEach ;
89import org .junit .jupiter .api .Test ;
910import org .usfirst .frc .team199 .Robot2018 .autonomous .VelocityPIDController ;
1011
12+ import edu .wpi .first .wpilibj .HLUsageReporting ;
1113import edu .wpi .first .wpilibj .PIDSource ;
1214import edu .wpi .first .wpilibj .SpeedController ;
1315import edu .wpi .first .wpilibj .Timer ;
1416import edu .wpi .first .wpilibj .internal .HardwareTimer ;
1517
1618class VelocityPIDControllerTest {
1719
20+ @ BeforeEach
21+ void setUp () {
22+ // Since VelocityPIDController extends PIDController and PIDController calls
23+ // static methods in wpilib that only work on robot,
24+ // we setup these mocks to allow the tests to run off robot.
25+ HardwareTimer tim = mock (HardwareTimer .class );
26+ Timer .Interface timerInstance = mock (Timer .Interface .class );
27+ when (tim .newTimer ()).thenReturn (timerInstance );
28+ Timer .SetImplementation (tim );
29+ HLUsageReporting .Interface usageReporter = mock (HLUsageReporting .Interface .class );
30+ HLUsageReporting .SetImplementation (usageReporter );
31+ }
32+
1833 @ Test
1934 void test1 () {
20- HardwareTimer tim = new HardwareTimer ();
21- Timer .SetImplementation (tim );
2235 PIDSource source = mock (PIDSource .class );
2336 SpeedController out = mock (SpeedController .class );
2437 double p = 1 ;
You can’t perform that action at this time.
0 commit comments