Today I was trying to run a unit test in Android but for some reason it didn't work. It was a Doh! moment again
This was the message I got:
Process finished with exit code 1 Class not found: "xx.xx.xx"Empty test suite.
In Android there are two kinds of unit tests:
These tests have their own package with the same name as your identifier.
You would see this inside your java folder:
nl.orhun.myapp < -- source files nl.orhun.myapp (androidTest) <-- instrumented test files nl.orhun.myapp (test) < -- local unit test files
The advantage of local unit testing is that you don't have the overhead to need to run a virtual device. It just simply can run on your computers JVM. Unfortunately you can't make use of Android framework features. So this will only be handy to test your own code which is not Android framework dependent.
Initially I created a local unit test and ran it. After that I moved the class to the androidTest to make it a instrumented test
Because I ran it before, it remembered my last run configuration. The next time I ran the LoginTest, it tried to run is as a LocalTest while the test is inside androidTest package which gave this error.
So, when you move a unit test from a local test to androidTest, check your Run/Debug settings. In my case I could remove the configuration so the next time a new one is generated again.
All your androidTest configurations are under AndroidTests. The local unit tests are under JUnit.