square / spoon

Distributing instrumentation tests to all your Androids.
https://square.github.io/spoon/
Apache License 2.0
2.7k stars 475 forks source link

Junit DataProvider tests are skipped when run via spoon plugin #538

Open manoj897 opened 6 years ago

manoj897 commented 6 years ago

My tests uses Junit DataProvider. I have given the sample class below which uses Junit Dataprovider. The below tests are running when run via Android studio but when used via spoon the below cases are not running. please help me identify if I am missing something

@RunWith(DataProviderRunner.class)
public class TestScenario {

    @DataProvider
    public static String[] dataSetValues() {
        return new String[]{
                "1907020001",
                "1907020002",
                "1907020003",
                "1907020004",
                "1907020005",
                "1907020006",
                "1907020007"
                "1907020008",
                "1907020009"
            };
    }

    @Test
    @UseDataProvider("dataSetValues")
    public void testMethod(String testId) {
        validateFunction1(testId);//The testId is the string from dataSetValues when used with Junit DataProvider
     }

}

while running, the following log was printed

2018-06-12 02:14:11 [SDR.run] Running com.xxx.automation.xxxx.test.Regression.yyy.TestScenario#testMethod[0: 1907020001] on [emulator-5554] Running am instrument -w -r -e class com.xxx.automation.xxxx.test.Regression.yyy.TestScenario#testMethod[0: 1907020001] com.xxx.automation.xxxx.test/com.xxx.automation.xxx.test.Helper.Utils.CustomTestRunner on Nexus_5x [emulator-5554] 02:14:11 D/InstrumentationResultParser: unrecognized line usage: am [subcommand] [options] 02:14:11 D/InstrumentationResultParser: unrecognized line usage: am start [-D] [-N] [-W] [-P ] [--start-profiler ] 02:14:11 D/InstrumentationResultParser: unrecognized line [--sampling INTERVAL] [-R COUNT] [-S] . . . 02:14:11 D/InstrumentationResultParser: unrecognized line Error: No instrumentation found for: 1907020001]

Looks like the above command is not recognised.

manoj897 commented 6 years ago

If the same command is used with a simple change then it works

In the above case while running the adb shell am instrument command there is a space between the test and testId

testMethod[0: 1907020001]

Instead when used as

testMethod[0:\\ 1907020001] it worked.

Is there any workaround to do these changes