[英]cannot create “test” folder in android studio for robolectric
I want to add robolectric tests to my project in intellij. 我想在我的intellij项目中添加robolectric测试。
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? 如何正确添加测试类?
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 并且不要忘记将其写入应用程序模块build.gradle中
android {
sourceSets {
main { java.srcDirs = ['src/main/java'] }
test { java.srcDirs = ['src/test/java'] }
}
}
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.
Android Studio已更改,不再需要使用Build Variants来区分UnitTest和AndroidTests。
Just create the TestFolders manually. 只需手动创建TestFolders。 eg
app/scr/androidTest
and put your test Files there. 例如
app/scr/androidTest
并将您的测试文件放在此处。
Maybe just create a new Project with android Studio. 也许只是使用android Studio创建一个新项目。 The Folders for tests will be atomatically created, you'll see what i mean.
测试文件夹将自动创建,您将明白我的意思。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.