How to unit-test static method in interface with Android Test?

时间:2018-06-04 16:40:21

标签: android unit-testing java-8 junit4 android-testing

How to unit-test interface's static method with instrumentation test?

I tried testing(Android Test) with following code; simplified for explanation.

But AndroidStudio said "Empty test suite."

In the case same code with local unit test(it meeans test code is located in test/java), test result was GREEN.

Why does only android-test fail?

and how to write android-test code for interface static method?

test target:

public interface SampleInterface {
    static String methodA(){
        return "foobar";
    }
}

test code:

@RunWith(AndroidJUnit4.class)
public class SampleInterfaceTest {
    @Test
    public void methodA() {
        Assert.assertThat(SampleInterface.methodA(), is("foobar"));
    }
}

message.

Started running tests
Test running failed: Instrumentation run failed due to 'java.lang.IllegalArgumentException'
Empty test suite.

0 个答案:

没有答案