openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
932 stars 429 forks source link

Assignment 1, Unit Testing - Chen Kang #4454

Closed chenkang02 closed 1 week ago

chenkang02 commented 1 week ago

Addressed Issue (1 mark): Previously, the authentication module had poor test coverage. To address this, unit tests were written to thoroughly test the authentication module of the project. Given its critical role, achieving near 100% test coverage for the authentication module was essential.

What You Have Reengineered (1.5 marks): Unit tests were implemented for three classes: JaasAuthenticationProvider, ManagedUserLoginConfiguration, and ManagedUserLoginModule. These tests were created using JUnit 5, a widely used testing framework, and Mockito, a popular library for mocking dependencies and simulating runtime behavior. The test cases cover the full lifecycle of the login modules, including edge cases and exceptional scenarios, ensuring robust validation

Impact of Changes (1 mark): The implemented changes significantly improved the test coverage of the login and authentication modules. By automating tests with the JUnit library, development cycle time has been reduced. These tests act as a safety net, preventing erroneous code from being deployed to production. Errors can now be detected and resolved early during the testing phase, minimizing the risk of system failures or bugs in the production environment. This ensures the stability and reliability of the authentication system throughout development and deployment.