-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f55b26
commit 4b42953
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import edu.wpi.first.hal.HAL; | ||
import frc.robot.Constants.IntakeConstants; | ||
import frc.robot.subsystems.IntakeSubsystem; | ||
import frc.utils.sim_utils.ColorSensorV3Wrapped; | ||
import frc.utils.sim_utils.SparkMAXSimAddon; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class IntakeTests { | ||
private IntakeSubsystem intakeSubsystem; | ||
private CANSparkMax intakeMotor; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
HAL.initialize(500, 0); | ||
intakeSubsystem = new IntakeSubsystem(); | ||
intakeMotor = SparkMAXSimAddon.getSparkMAX(IntakeConstants.kIntakeMotorCanID); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
intakeSubsystem.close(); | ||
} | ||
|
||
@Test | ||
void testIntakeSubsystem() { | ||
intakeSubsystem.setIntakeSpeed(0.5); | ||
assertEquals(0.5, intakeMotor.get(), 0.001); | ||
} | ||
|
||
@Test | ||
void testIntakeSubsystemWithNote() { | ||
ColorSensorV3Wrapped.setRGBD(2500, 0, 0, 900); | ||
intakeSubsystem.setIntakeSpeed(0.5); | ||
assertEquals( | ||
0, intakeMotor.get(), 0.001, "Intake motor should not be running when a note is detected"); | ||
} | ||
} |