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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With