I'm implementing a Test automation tool and I have a class which extends InstrumentationTestCase
. For example:
public class BaseTests extends InstrumentationTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
Log.d(TAG, "setUp()");
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
Log.d(TAG, "tearDown()");
}
public void test_one() {
Log.d(TAG, "test_one()");
}
public void test_two() {
Log.d(TAG, "test_two()");
}
}
When I run the tests of BaseTests
, the setUp() method is called 2 times. One time before executing test_one()
and another after test_two()
. The same happens with the tearDown(), it is called after executing each of both two methods.
What I would like to do here is to call setUp() and tearDown() methods only one time for the execution of all BaseTests
tests. So the order of the method call would be like:
1) setUp()
2) test_one()
3) test_two()
4) tearDown()
Is there a way to do such thing?