Mobile App Testing Strategies - bounswe/bounswe2024group3 GitHub Wiki
Testing Strategies for the Mobile Team
Our mobile team has been working on testing our app to ensure it works correctly. We've focused on unit testing and integration testing using tools like Jest and React Native Testing Library.
Unit Testing
We wrote unit tests to check individual components:
index.test.tsx
)
App Component (What we tested: Rendering of the initial UI and theme toggling.
Example:
- Checked if the theme icon (
moon-outline
) is displayed. - Made sure that pressing the theme button toggles the icon to
sunny-outline
.
profile.test.tsx
)
Profile Component (What we tested: Displaying user data and handling logout.
Example:
- Verified that user details like name and email are shown.
- Ensured that pressing "Logout" clears the user data and redirects to the login screen.
Unit Test Coverage
We have focused our unit tests on the app/
folder of our mobile application. Here's an overview of our test coverage:
Coverage Percentage:
- Statements: ~85%
- Branches: ~80%
- Functions: ~90%
- Lines: ~85%
Reasoning:
- Critical Components: We prioritized writing tests for the most important parts of our app, such as the main App component and user-related features like Profile and Login.
- Reusable Functions: Functions that are used in multiple places have higher coverage to ensure they work correctly everywhere.
- User Interactions: Components that handle user actions, like button presses and form submissions, are thoroughly tested to ensure a smooth user experience.
- Error Handling: We made sure to test how our app behaves in case of errors, such as failed API calls or missing data, to provide clear feedback to users.
By achieving high test coverage in the app/
folder, we ensure that the core functionality of our mobile app is reliable and any changes in the future will be less likely to introduce bugs.
Integration Testing
We tested how different parts of the app work together, especially with API calls:
search.test.tsx
)
SearchScreen Component (What we tested: Fetching and displaying search results.
Example:
- Simulated entering a search query and checked if the correct posts are displayed.
- Tested error messages when no results are found or when there's a fetch error.
login.test.tsx
)
Login Component (What we tested: User login process.
Example:
- Checked if the app displays an error on login failure.
- Made sure that on successful login, the app stores user data and navigates to the home screen.
Testing Tools
- Jest: Used for running our tests.
- React Native Testing Library: Helps us render components and simulate user interactions.
Mocking:
- Axios Mocking: To simulate API responses.
- AsyncStorage Mocking: To test components that use local storage.
Acceptance Criteria
- Components should render correctly with all the necessary UI elements.
- User interactions should trigger the correct state changes.
- The app should handle errors gracefully and show appropriate messages to users.
- Unit Test Coverage: Aim for at least 80% coverage in statements, branches, functions, and lines to ensure most of the code is tested.
We hope this gives you a clear idea of how we're testing our mobile app.