Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidJunit4 doesn't accept space function test name?

I have the following test, where the test name is with space and backtick for my instrumental test

@RunWith(AndroidJUnit4::class)
class MyTestClass {
    @Rule
    @JvmField
    var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)

    @Test
    fun `My space name testing`() {
          // Some test
    }
}

However when running it, it can't be executed (i.e. No test were found)

Checking on it, I saw this linting error on the test function name..

This inspection reports identifiers in android projects which are not accepted by the Android runtime (for example, method names containing spaces)

When I rename my test function from My space name testing to mySpaceNameTesting, the test run.

Is it really that AndroidJunit4 runtime can't support test function name with spaces?

like image 223
Elye Avatar asked Jul 27 '18 16:07

Elye


1 Answers

Correct, it's unsupported in the Android runtime. See the Coding Conventions page here. Specifically:

In tests (and only in tests), it's acceptable to use method names with spaces enclosed in backticks. (Note that such method names are currently not supported by the Android runtime.) Underscores in method names are also allowed in test code.

like image 192
Kevin Coppock Avatar answered Sep 22 '22 15:09

Kevin Coppock