お世話になります。
件名のとおり、Android StudioでJunitのテストケース作りたいのですが、どうやってやれば良いか思考錯誤しています。
ネットで調べながら、build.gradleの修正や、Testケースのパッケージを配置したりとしていたら、buildできなくなりました。
どなたか教えていただけれると助かります。
-CLIでclean実行-
hogeo@hogeko:~/dev/mydev/UnitCaseTest (master *)$ ./gradlew clean
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/hogeo/dev/mydev/UnitCaseTest/app/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method testPackageName() for arguments [jp.xxx.unitcasetest.test] on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=ApiVersionImpl{mApiLevel=9, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=22, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null, versionCode=1, versionName=1.0, applicationId=jp.xxx.unitcasetest, testApplicationId=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.595 secs
-プロジェクト直下のbuild.gradle-
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
-app配下のbuild.gradle-
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "jp.xxx.unitcasetest"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
testPackageName "jp.xxx.unitcasetest.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
testCompile 'junit:junit:4.12'
}
ディレクトリ階層
├── app
| ├── build.gradle
│ └── src
│ ├── androidTest
│ │ └── java
│ │ └── jp
│ │ └── xxx
│ │ └── unitcasetest
│ │ └── test
│ │ ├── ApplicationTest.java
│ │ └── MainActivityTestTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── jp
│ │ └── xxx
│ │ └── unitcasetest
│ │ └── MainActivity.java
│
├── build.gradle