Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Migrate some integration tests to the unit test source set #204

Open
6 tasks
alexandrepiveteau opened this issue Apr 1, 2022 · 1 comment
Open
6 tasks

Comments

@alexandrepiveteau
Copy link
Contributor

alexandrepiveteau commented Apr 1, 2022

Context

Currently, nearly all of our tests are located in the androidTest source set. Therefore, many tests which could be run as unit tests are executed as integration tests, considerably slowing down the builds. Out of the 250+ tests which we currently have, at least 125 could be run as unit tests.

This issue contains a suggestion of some gradual steps to make the migration as smooth as possible. Each step could be performed in a separate PR, to make the migration process smoother.

Migration path

  • 1. Rename the unit test main package from ch.epfl.sdp.mobile to ch.epfl.sdp.mobile.test.
  • 2. Rename the integration test main package from ch.epfl.sdp.mobile.test to ch.epfl.sdp.mobile.androidTest. This is an important change that might require solving some merge conflicts !
  • 3. Add support for a sharedTest source set to Gradle and to CodeClimate.
  • 4. Move the fake Auth and the fake Store implementations to the sharedTest folder, and change their current package names to ch.epfl.sdp.mobile.sharedTest.xxx.
  • 5. Move all the tests from ch.epfl.sdp.mobile.androidTest.application from the integration tests source set to the unit test source set, in ch.epfl.sdp.mobile.test.application.
  • 6. Move some of the remaining state tests to the ch.epfl.sdp.mobile.test.state package in the unit test source set.

The final result will be that we have four source sets :

  • main, with the app code.
  • sharedTest, with all its code in the package ch.epfl.sdp.mobile.sharedTest and which contains some code used by both test and androidTest.
  • test, with all its code in the package ch.epfl.sdp.mobile.test and which contains some unit tests.
  • androidTest, with all its code in the package ch.epfl.sdp.mobile.androidTest and which contains some integration tests.

Questions & Answers

  • Why should we use different package names for each source set ?

Android Studio has an issue where, if you have two files in the same package and with the same name in the main and androidTest source sets, it won't compile properly when you run some integration tests. This is the reason for which we currently have the .test package suffix for our integration tests. However, with the introduction of some additional source sets, it makes sense to better distinguish in the package name tests and code which is meant for integration, unit, or both kinds of tests.

@alexandrepiveteau
Copy link
Contributor Author

As indicated in #257, it won't be possible to use Robolectric right away to migrate the Compose-based androidTest tests into the test source set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant