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

Instrumentation tests #41

Merged
merged 2 commits into from
Jun 19, 2024
Merged

Instrumentation tests #41

merged 2 commits into from
Jun 19, 2024

Conversation

eldcn
Copy link
Contributor

@eldcn eldcn commented Jun 13, 2024

Instrumentation tests

  • Add HiltApplicationTestRunner to execute instrumented android tests with hilt
  • Introduce ComposeContentActivity in design module, in order to be able to start single screen instrumented tests in non-app modules - see OnboardingScreenTest.kt in onboarding module for example usage
  • Introduce test identifier (test tags) on relevant compose nodes of the screens in order to reference in UI tests
  • Introduce some extension helper functions on ComposeTestRule and Modifier
  • Add OnboardingScreenTest in onboarding module using fake repository (via a test hilt module) and screen display and click interaction
  • Simulator - Introduced the concept of simulators. Wrappers around ComposeTestRule with a DSL-like API to interact with a certain composable screen.
  • app
    • AppNavigationTest - Several test methods that invoke navigation via Navigator component and ensure display of the expected screen
    • OnboardingFlowTest tests the display of the initial onboarding screens and the navigation to the next expected one
    • Included several simulators that can also be reused in future tests - We can think of extracting all the simulators in a separate module for reusability among modules

TODO:

♻️ Current situation & Problem

Link any open issues or pull requests (PRs) related to this PR. Please ensure that all non-trivial PRs are first tracked and discussed in an existing GitHub issue or discussion.

⚙️ Release Notes

Add a bullet point list summary of the feature and possible migration guides if this is a breaking change so this section can be added to the release notes.
Include code snippets that provide examples of the feature implemented or links to the documentation if it appends or changes the public interface.

📚 Documentation

Please ensure that you properly document any additions in conformance to Spezi Documentation Guide.
You can use this section to describe your solution, but we encourage contributors to document your reasoning and changes using in-line documentation.

✅ Testing

Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested.
This section describes important information about the tests and why some elements might not be testable.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 11.76471% with 90 lines in your changes missing coverage. Please review.

Project coverage is 26.00%. Comparing base (b9f4ae6) to head (a6dd47f).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main      #41      +/-   ##
============================================
- Coverage     26.40%   26.00%   -0.40%     
- Complexity      193      195       +2     
============================================
  Files           101      102       +1     
  Lines          2860     2920      +60     
  Branches        404      403       -1     
============================================
+ Hits            755      759       +4     
- Misses         2063     2124      +61     
+ Partials         42       37       -5     
Flag Coverage Δ
unittests 26.00% <11.77%> (-0.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../module/onboarding/onboarding/OnboardingUiState.kt 100.00% <100.00%> (+14.29%) ⬆️
...d/bdh/engagehf/bluetooth/screen/BluetoothScreen.kt 0.00% <0.00%> (ø)
...stanford/spezi/module/account/login/LoginScreen.kt 0.00% <0.00%> (ø)
...rd/spezi/module/account/register/RegisterScreen.kt 0.00% <0.00%> (ø)
...arding/sequential/components/OnboardingViewPage.kt 0.00% <0.00%> (ø)
...zi/core/design/component/ComposeContentActivity.kt 0.00% <0.00%> (ø)
...d/spezi/module/onboarding/consent/ConsentScreen.kt 0.00% <0.00%> (ø)
...odule/onboarding/onboarding/OnboardingViewModel.kt 78.27% <66.67%> (+22.71%) ⬆️
.../onboarding/sequential/components/PageIndicator.kt 0.00% <0.00%> (ø)
...nboarding/sequential/SequentialOnboardingScreen.kt 0.00% <0.00%> (ø)
... and 2 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9f4ae6...a6dd47f. Read the comment docs.

@eldcn eldcn force-pushed the task/instrumentation-tests branch from 0dc8e7d to 639eef3 Compare June 13, 2024 21:47
Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the work in this PR @eldcn!

Interesting and a good learning experience to see the differentiation between the test setup, modules that are used to facilitate the test as well as the face repositories that are injected + separation of view assertions in the simulator types.
It would be great if we could wither document this setup and pattern in a README in the testing support modules or point to a good tutorial or Google documentation that describes these types of setups in more detail.

Apart from this the PR looks good to me, we can also separate the documentation task in a separate PR, similar to the integration in GitHub Actions in #21 👍

Might make sense to merge the setup in its current state and then address the CI integration + documentation in separate PRs as we address these smaller issues to ensure that we have this infrastructure in main and @Basler182 can use these setups to facilitate a good testing infrastructure for incoming smaller PRs addressing individual issues that we have identified in this repo.

Copy link
Contributor

@Basler182 Basler182 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, this will make testing much easier and is well structured. I agree with Paul. It would be ideal if we could merge it promptly so that I can build on it directly. from my point of view it is ready to be merged🚀

@eldcn eldcn merged commit 9965c5a into main Jun 19, 2024
7 checks passed
@eldcn eldcn deleted the task/instrumentation-tests branch June 19, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants