SwEnt-2024-Group-19 / Activities

1 stars 0 forks source link

Testing/navigation tests #67

Closed mohamedtahaguelzim closed 1 week ago

mohamedtahaguelzim commented 1 week ago

TLDR: Added a unit test for navigationActions. Conform to the bootcamp.

This PR introduces a set of unit tests for the NavigationActions class within the Android application. The tests aim to ensure that the navigation actions work correctly with the NavHostController, validating the functionality of navigating to various destinations and checking the current route.

Changes Made: Created NavigationActionsTest Class: A dedicated test class for testing the NavigationActions functionality. Test Setup: Utilized Mockito to create mocks for NavDestination and NavHostController, initializing them before each test. Implemented Tests: navigateToCallsController: Verifies that the navigateTo method correctly calls the navigate function of the NavHostController with the appropriate route. goBackCallsController: Ensures that the goBack method correctly invokes the popBackStack method of the NavHostController. currentRouteWorksWithDestination: Confirms that the currentRoute method returns the expected route by mocking the current destination of the NavHostController. The tests have been run successfully, and all assertions passed. They can be executed using the standard unit test framework in the Android project.