Reputation: 3723
This seems like a silly question but I have an app in Android Studio and I'd like to try some TDD/Unit testing. I tried adding a tests folder and adding a class manually in the explorer but found I can only add Java classes under my main src folder. How can I simply add a tests folder at the same level as my src folder and create Java classes for it? Do I need something in my build.gradle?
Upvotes: 0
Views: 96
Reputation: 1812
The new latest version of gradle build tools (1.3.1) came with new test functionality and I will show you how to create your test easily.
First of all there is now two default directories for tests:
You should put your instrumentation tests into androidTest and your simple JUnit tests (with almost no android dependencies) into test
If you wanna run your Unit Tests your have to select this option:
When you select this options your directory will be highlighted like this:
When you select instrumentation tests then you will see something like this:
You can go deep into Support Test Library checking this link:
http://developer.android.com/intl/pt-br/tools/testing-support-library/index.html
Hope that it helps!
Upvotes: 4