oss-slu/Pi4Micronaut

Add Unit Tests for LEDHelper Class

Closed this issue · 0 comments

Description:

We need to add unit tests for the LEDHelper class in the com.opensourcewithslu.outputdevices package. This is a "good-first-issue" because it involves creating unit tests, which is a manageable task for newcomers and essential for ensuring code reliability.

Tasks:

  1. Setup Testing Framework:
    • Ensure that the project is configured to use JUnit and Mockito for unit testing.
    • Add necessary dependencies to build.gradle.
  2. Create Unit Tests:
    • Test ledOn() Method:
      • Verify that the LED is turned on when it is currently off.
      • Ensure that the LED is not turned on if it is already on.
    • Test ledOff() Method:
      • Confirm that the LED is turned off when it is currently on.
      • Ensure that the LED is not turned off if it is already off.
    • Test switchState() Method:
      • Verify that the LED state is toggled correctly when it is currently on.
      • Confirm that the LED state is toggled correctly when it is currently off.
    • Test blink(int duration) Method:
      • Ensure that the blink method is called with the correct parameters.
  3. Verify Logging:
    • Ensure that the appropriate log messages are generated for the ledOn() and ledOff() methods.

Acceptance Criteria:

  • All unit tests for the LEDHelper class are added and passing.
  • The tests should mock the DigitalOutput class to avoid actual hardware interaction.
  • Ensure that all methods are tested for different scenarios as outlined