could not be found or has no tests in Junit

不羁岁月 提交于 2019-12-10 22:39:47

问题


I am trying to test setting application using JunitTestcase.My class extends ActivityInstrumentationTestCase2. But while executing I am getting this error:

01-12 17:22:11.519: WARN/TestGrouping(2942): Invalid Package: '' could not be found or has no tests 01-12 17:22:11.539:

INFO/ActivityManager(1620): Force stopping package com.android.settings uid=1000

Can any one suggest a solution for this?.


回答1:


You have to specify the app to be tested in the AndroidManifest of the testing project.. that might be missing.




回答2:


I had similar issue, after spending two days I solved it..

Test class path : app/src/androidTest/java/your-pkg-name/example_classTest.java

java file path : app/src/main/java/your-pkg-name/example_class.java

and you should clearly define below code in your app gradle

android{

      sourceSets {

         androidTest {
              java.srcDirs = ['src/androidTest/java']
          }


        }

 }

good luck




回答3:


I had a similar issue, and I tracked the problem down to my gradle file. I needed the following in there:

aidl.srcDirs = ['src']


来源:https://stackoverflow.com/questions/9476968/could-not-be-found-or-has-no-tests-in-junit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!