Reputation: 36654
I want to add robolectric tests to my project in intellij.
I have tried to follow this tutorial
but I cannot add "test" package under my main module.
In addition the "build variants" look different than in the tutorial.
how can I fix this?
how can I add test class properly?
Upvotes: 1
Views: 4099
Reputation: 20130
You need to change Project layout from Android to Project:
And now you can easily create folders from Android Studio UI
Upvotes: 1
Reputation: 209
this is not the way, the good architecture is:
/app
/src
/main
/java
/com.your.package
/test
/java
/com.your.package
and don't forget to write it in the app module build.gradle
android {
sourceSets {
main { java.srcDirs = ['src/main/java'] }
test { java.srcDirs = ['src/test/java'] }
}
}
Upvotes: 7
Reputation: 1763
I guess you had an outdated tutorial. Android Studio changed, there is no need to use Build Variants to distinguish between UnitTest and AndroidTests anymore.
Just create the TestFolders manually. e.g. app/scr/androidTest
and put your test Files there.
Maybe just create a new Project with android Studio. The Folders for tests will be atomatically created, you'll see what i mean.
Upvotes: 0