Android test case order

Issue

I have tests that are depend on each other, and I want to select there order.
The code very long and call them from one method is unrealistic and impossible.

Is there any way that the tests will be run, in order as the test methods appears in class file, or in the order that I want?

EDIT
What can I do if I want to test database connection class. I will need to test ‘add’ ‘delete’ and ‘update’, and also test some methods that use data from database?

Solution

Unit Tests should be independent of each other. It sounds like you are testing multiple methods which are highly dependent on each other. I suggest looking into Dependency Injection and mock objects to remove some of that dependency and allow you to test one method at a time.

Answered By – Rumpel

Leave a Comment