You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The PIRSensorHelper class manages a PIR motion sensor using Pi4J's DigitalInput. Unit tests are required to validate its behavior, including motion detection, event listener management, and initialization.
Developer Notes:
Test Initialization Logic:
Verify that isMoving is correctly initialized based on pirSensorInput.isHigh().
Ensure that the initialize method adds an event listener to pirSensorInput.
Test Motion Detection (initialize Method):
Simulate a change in pirSensorInput state and check if isMoving updates correctly.
Test Event Listener Management:
Validate that addEventListener correctly adds an event listener to pirSensorInput.
Ensure removeEventListener removes the listener and sets pirSensorInputListener to null.
Check that multiple calls to removeEventListener do not cause errors.
Mocking Dependencies:
Use Mockito to mock DigitalInput and DigitalStateChangeListener.
Ensure tests do not require real hardware.
Edge Cases:
Verify behavior when pirSensorInput is initially low.
Ensure addEventListener correctly overrides existing listeners.
Test that removeEventListener does not fail when no listener is present.
Acceptance Criteria
All test cases outlined in the tasks above are implemented.
Code coverage for the MicroSwitchHelper class is at least 70%.
Tests are written using a Java JUnit testing framework
Mocking is implemented using a framework such as Mockito or a similar tool.
All tests pass successfully, and edge cases are handled gracefully.
The text was updated successfully, but these errors were encountered:
Description:
The PIRSensorHelper class manages a PIR motion sensor using Pi4J's DigitalInput. Unit tests are required to validate its behavior, including motion detection, event listener management, and initialization.
Developer Notes:
Verify that isMoving is correctly initialized based on pirSensorInput.isHigh().
Ensure that the initialize method adds an event listener to pirSensorInput.
Simulate a change in pirSensorInput state and check if isMoving updates correctly.
Validate that addEventListener correctly adds an event listener to pirSensorInput.
Ensure removeEventListener removes the listener and sets pirSensorInputListener to null.
Check that multiple calls to removeEventListener do not cause errors.
Use Mockito to mock DigitalInput and DigitalStateChangeListener.
Ensure tests do not require real hardware.
Verify behavior when pirSensorInput is initially low.
Ensure addEventListener correctly overrides existing listeners.
Test that removeEventListener does not fail when no listener is present.
Acceptance Criteria
All test cases outlined in the tasks above are implemented.
Code coverage for the MicroSwitchHelper class is at least 70%.
Tests are written using a Java JUnit testing framework
Mocking is implemented using a framework such as Mockito or a similar tool.
All tests pass successfully, and edge cases are handled gracefully.
The text was updated successfully, but these errors were encountered: