oss-slu / Pi4Micronaut

A java library combining Micronaut and Pi4j to streamline hardware connectivity to Raspberry Pi's
https://oss-slu.github.io/Pi4Micronaut/
Apache License 2.0
7 stars 4 forks source link

Add Unit Tests for LEDHelper Class #247

Closed yrlmanoharreddy closed 1 week ago

yrlmanoharreddy commented 3 weeks ago

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: