It seems that the version 2.0.3 of Flank is not handling correctly the Tests inside abstract classes.
For example, this 2 classes:
public abstract class AbstractFooTest {
@Test
public void testAbstractBar() {
onView(withId(R.id.firebaseConfig)).check(matches(withText("text")));
}
@Test
public void testAbstractBar2() {
onView(withId(R.id.firebaseConfig)).check(matches(withText("text")));
}
}
@RunWith(AndroidJUnit4.class)
public class FooTest extends AbstractFooTest {
@Rule
public ActivityTestRule<MainActivity> mMainActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testMainActivity() {
onView(withId(R.id.firebaseConfig)).check(matches(withText("text")));
}
@Test
public void testBar() {
onView(withId(R.id.firebaseConfig)).check(matches(withText("text")));
}
If I run this text locally or directly with Firebase (without using Flank) the list of tests executed will be:
espresso.fail.multidex.FooTest#testBar
espresso.fail.multidex.FooTest#testMainActivity
espresso.fail.multidex.FooTest#testAbstractBar
espresso.fail.multidex.FooTest#testAbstractBar2
but if I use Flank I will get:
espresso.fail.multidex.FooTest#testBar
espresso.fail.multidex.FooTest#testMainActivity
espresso.fail.multidex.AbstractFooTest#testAbstractBar
espresso.fail.multidex.AbstractFooTest#testAbstractBar2
This will unfortunately cause a java.lang.InstantiationException:
java.lang.InstantiationException: Can't instantiate abstract class core.tests.util.AbstractPlaceholderHelperTest
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384)
at de.payback.app.PaybackAndroidJUnitRunner.onStart(PaybackAndroidJUnitRunner.java:51)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
I know that is not so common to have abstract classes for tests but in some projects they are used to share tests between different flavors.
Repro project here: https://github.com/leinardi/Gradle_troubles_android_enteprise/tree/flank-abstract-class-issue
https://github.com/linkedin/dex-test-parser/issues/13 is why the issue happens in Flank. The fix needs to be in that upstream library.
I know that is not so common to have abstract classes for tests but in some projects they are used to share tests between different flavors.
I had the same issue and refactored out the abstract tests. I think that's the only option for now until dex-test-parser is updated to fully resolve the method names.
Yep, I am doing the same, but thanks for opening the issue in the linkedin/dex-test-parser tracker :+1:
This issue has been fixed upstream. Flank Kotlin has been updated. The snapshot release contains the fix:
https://jitpack.io/com/github/TestArmada/flank/master-SNAPSHOT
If this is still a problem on the new version, let us know.