AndroidJunit4 不接受 space 函数测试名称?
AndroidJunit4 doesn't accept space function test name?
我有以下测试,其中测试名称带有 space 和我的仪器测试的反引号
@RunWith(AndroidJUnit4::class)
class MyTestClass {
@Rule
@JvmField
var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
@Test
fun `My space name testing`() {
// Some test
}
}
但是当运行ning它时,它无法执行(即没有找到测试)
检查它,我在测试函数名称上看到了这个 linting 错误..
This inspection reports identifiers in android projects which are not accepted by the Android runtime (for example, method names containing spaces)
当我将测试函数从 My space name testing
重命名为 mySpaceNameTesting
时,测试 运行.
难道AndroidJunit4运行time真的不支持spaces的测试函数名吗?
正确,Android 运行时不支持它。请参阅此处的 Coding Conventions 页面。具体来说:
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.
我有以下测试,其中测试名称带有 space 和我的仪器测试的反引号
@RunWith(AndroidJUnit4::class)
class MyTestClass {
@Rule
@JvmField
var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
@Test
fun `My space name testing`() {
// Some test
}
}
但是当运行ning它时,它无法执行(即没有找到测试)
检查它,我在测试函数名称上看到了这个 linting 错误..
This inspection reports identifiers in android projects which are not accepted by the Android runtime (for example, method names containing spaces)
当我将测试函数从 My space name testing
重命名为 mySpaceNameTesting
时,测试 运行.
难道AndroidJunit4运行time真的不支持spaces的测试函数名吗?
正确,Android 运行时不支持它。请参阅此处的 Coding Conventions 页面。具体来说:
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.