Jimmy
Jimmy

Reputation: 16428

Is it best practice to place all android tests (units / integrations / UI tests) into a single test project?

I've got my main application project, and then a second project for my tests. Is it good practice to store all types of tests in that test project, or should some reside in the main application project?

Should I keep POJO JUnits (ones that test non-android derived classes) in my main project, or group them all together? I can't see anything on the Google documentation that advises where to locate tests.

Thanks

Upvotes: 3

Views: 311

Answers (2)

Jarl
Jarl

Reputation: 2861

The Android test documetation says

... the best approach is to add the test project so that its root directory tests/ is at the same level as the src/ directory of the main application's project.

There is even an illustration of the directory structure in the documentation.

Jarl

Upvotes: 1

Noah
Noah

Reputation: 1966

Rather than creating two projects, its very good practice to create a second 'source' folder in the original android (or java) project and put your tests in that. When you export as an app, you can exclude that source folder from the compiled application.

Adding another source folder

Excluding files from the export

Upvotes: 4

Related Questions