Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Unit Tests for RGBLEDHelper #260

Open
3 tasks
yrlmanoharreddy opened this issue Sep 30, 2024 · 1 comment
Open
3 tasks

Write Unit Tests for RGBLEDHelper #260

yrlmanoharreddy opened this issue Sep 30, 2024 · 1 comment
Labels
enhancement New feature or request hacktoberfest Open for Hacktoberfest contributions. Please follow contribution guidelines and submit meaningful PR unit-test To ensure individual components or functions work as intended.

Comments

@yrlmanoharreddy
Copy link
Collaborator

Description:
Write unit tests for the RGBLEDHelper class to ensure proper functionality of all its methods, including color setting, frequency handling, and turning the LED on/off. Use mocks for the Pwm components to simulate hardware interaction.

Tasks:

  1. Test Initialization:

    Verify that RGBLEDHelper correctly initializes Pwm instances for red, green, and blue.

  2. Test setColor Methods:

Test setColor(int[] colors) to ensure it sets the RGB values with default frequency (200 Hz).
Test setColor(int[] colors, int[] frequency) to verify RGB values and corresponding frequencies are set properly.

  1. Test setColorHex Methods:

    Test setColorHex(String hex) for correct RGB values from hex and default frequency.
    Test setColorHex(String hex, int[] frequency) for correct RGB values and frequencies.

  2. Test Individual Color Setters:
    Write tests for setRed, setGreen, and setBlue to validate both color value and frequency setting.

  3. Test ledOff and ledOn:

    Ensure ledOff() turns off all RGB components.
    Ensure ledOn() sets all RGB values to 100 with default frequency.

Acceptance Criteria:

  • Unit tests cover all methods.
  • All tests pass with mock Pwm components.
  • Log messages are validated for correct execution.
@yrlmanoharreddy yrlmanoharreddy added enhancement New feature or request unit-test To ensure individual components or functions work as intended. hacktoberfest Open for Hacktoberfest contributions. Please follow contribution guidelines and submit meaningful PR labels Sep 30, 2024
@SinaSoheili
Copy link

SinaSoheili commented Oct 9, 2024

Hello dear @yrlmanoharreddy
I have some question about this issue:

  1. If you want to verify RGBLEDHelper correctly initializes Pwm instances for red, green and blue, we need to having access to red, green and blue instances of class however we don't have any getter method for this fields. I can get access to this fields through reflection however it is not best way and also I can create getter methods for this fields. which one do you prefer or is there any other way ?
  2. Same issue for checking log message. I need at least a setter method for logger field in order to check message through mocking logger. Can I add setter method to this class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Open for Hacktoberfest contributions. Please follow contribution guidelines and submit meaningful PR unit-test To ensure individual components or functions work as intended.
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants