Skip to content

Commit

Permalink
add Tests for Intake Subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
MEFThunders7035 committed Feb 26, 2024
1 parent 7f55b26 commit 4b42953
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/java/IntakeTests.java
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");
}
}

0 comments on commit 4b42953

Please sign in to comment.