Skip to content

Try writing elevator tests#1

Open
bovlb wants to merge 1 commit intomainfrom
add-elevator-test
Open

Try writing elevator tests#1
bovlb wants to merge 1 commit intomainfrom
add-elevator-test

Conversation

@bovlb
Copy link
Copy Markdown
Contributor

@bovlb bovlb commented Jan 6, 2025

This change adds a few unit tests for the elevator as an example of how we can add unit tests.

These tests will fail right now because the elevator implementation is incomplete.

See also https://docs.wpilib.org/en/stable/docs/software/wpilib-tools/robot-simulation/unit-testing.html

@bovlb bovlb requested review from Copilot and cpaggron January 6, 2025 06:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

@Test void testPosition2() {
m_elevatorSubsystem.setPosition(1.0);
for (int i = 0; i < 100; i++) {
m_elevatorSubsystem.simulationPeriodic();
Copy link

Copilot AI Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simulationPeriodic method is not defined in ElevatorSubsystem. It should be implemented to update the simulation state.

Suggested change
m_elevatorSubsystem.simulationPeriodic();
m_elevatorSubsystem.updateSimulationState();

Copilot uses AI. Check for mistakes.
// This method will be called once per scheduler run
}

public SparkFlexSim getSimMotor() {
Copy link

Copilot AI Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getSimMotor() creates a new SparkFlexSim instance each time it is called. This might not be intended if the same instance is expected to be used throughout the tests. Consider storing the SparkFlexSim instance in a member variable and returning that instance.

Copilot uses AI. Check for mistakes.
@bovlb bovlb requested a review from paulregnier2 January 6, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants