dimanche 22 mars 2015

Android unit testing: connectedAndroidTest does not execute my test case

I am trying to add some unit tests to my app. I am developing my app in Android Studio


This is what I did.




  • Added a new package




  • Created a class in new package which extends TestCase




  • Added following method to created class




@SmallTest public void basicTest() { assertEquals("abc", "abc"); }



  • Added following to defaultConfig section in build.gradle


testApplicationId "newly.added.package.name" testInstrumentationRunner "android.test.InstrumentationTestRunner"



  • Executed following command in Android Studio Terminal


gradlew.bat connectedAndroidTest


But, when I checked the generated html report, it shows that 0 tests were run.


I tried following, but none of them made a difference to the output of gradlew.bat connectedAndroidTest command.



  • Added an incorrect package name to testApplicationId in build.gradle.

  • Disconnected device


Why doesn't my test case get executed? What have I missed?


Aucun commentaire:

Enregistrer un commentaire