Alex
Alex

Reputation: 2037

Android, Espresso. Is it possible and is it good to call one test method from another?

In my android project I have 2 test classes in a folder:

app\src\androidTest\java\com\mycompany\fragment

In class Fragment1Test I have 1 Espresso test method "testShowTitle".

In class Fragment2Test I have 1 test Espresso method "testSwipeEffect".

And all works fine. OK.

I have 2 questions:

  1. Is it possible to call the test method testSwipeEffect from another test class (Fragment1Test).?
  2. Is it a good solution?

Upvotes: 0

Views: 592

Answers (1)

mark w.
mark w.

Reputation: 1107

You could call it but it is not considered a good practice where one test method calls another test method. If there is some shared functionality between the 2 tests, i would recommend to add it to another class and call that method in both the tests.

Upvotes: 1

Related Questions