未能在新的Android Kotlin项目上运行Instrumented测试

我刚刚创建了一个新的Android应用程序与Kotlin支持。

当我试图运行默认的仪器测试时,它不会运行,并显示给我这个消息:

 Class not found: "oussaki.com.pos.ExampleInstrumentedTest"Empty test suite. 

这是我试图运行的Instrumented测试类:

 @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getTargetContext() assertEquals("oussaki.com.pos", appContext.packageName) } } 

在这里输入图像说明

这是一个已知的问题: https : //issuetracker.google.com/issues/38452937有望在下一个版本中修复。

目前,您可以手动进入“编辑配置”,并添加您想要在“Android Instrumented测试”下运行的特定类/方法的配置。

你也可以尝试最新的金丝雀构建: https : //developer.android.com/studio/preview/index.html,但个人,我有麻烦得到它与我的项目工作。