简体   繁体   中英

Where to place UI tests in a multi-module Android app

If I have an app that gets features from other modules, let's say [Login Android Module] -> [App] . Where should I place the UI tests, in the App module's androidTest or in the Login module's androidTest ? And why?

In general, you should put the majority of the tests in the same module only. In your case, for [Login Android Module] , you should put the majority of the tests like input validataion, user login validation, etc. into the [Login Android Module] only. Same goes with [App] module as well.

Now, since the [App] module depends on the [Login Android Module] (that's what I assume from the description, please correct me in case I am wrong), there could be a scenario where the Activity/Fragment/UI/Class of [App] is navigating/using the Activity/Fragment/UI/Class of [Login Android Module] . In such cases, the testing of this particular flow/integration would be the part of [App] module only, since the navigation/usage is mainly done by the [App] module classes.

Why to follow this approach:

  1. All the tests regarding your modules are kept inside the respective module only. This way in case tomorrow the [App] module or any other module is moved/deleted, it won't impact test coverage of your module.
  2. It also helps to debug which module is responsible for tests failure. Eg:- In case library module tests are kept in app module, then tests failure in app module could be cuased due to app module changes or library module changes, which can be pretty hard to debug. Whereas, in case the tests are kept in their respective modules, the segregation of which module caused test failure is faster and easier to debug.
  3. In case you develope multiple application and your login module is getting reused over multiple application, you can extract the login module as a separate library. Since the tests are contained withing module, the library creation won't have much impact on your tests.
  4. You reduce the external dependency for testing your module. In case you have your tests in separate module, there is a chance that the module can be deleted or corrupted (compilation errors/runtime errors). Which impacts your tests execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM