public class StringUtilsTests extends TestCase {
String message;
@Override
protected void setUp() throws Exception {
super.setUp();
message = "33,333";
}
/**
*
*/
public void testCommaToSpaces() {
String result = StringUtils.commasToSpaces(message);
assertEquals("33 333", result);
}
}
建筑等级:-
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
// Unit testing dependencies
testCompile 'junit:junit:4.12'
// Set this dependency if you want to use Mockito
testCompile 'org.mockito:mockito-core:1.10.19'
}
testOptions {
unitTests.all {
// All the usual Gradle options.
jvmArgs '-XX:MaxPermSize=256m'
}
}
sourceSets {
unitTest {
java.srcDir file('src/androidTest/java')
}
}
configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
dependencies {
unitTestCompile files("$project.buildDir/results-tests")
}
task unitTest(type: Test, dependsOn: assemble) {
description = "run unit tests"
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
check.dependsOn unitTest
我尝试了很多东西后,谷歌搜索了一天多,但测试报告- xml/html没有得到生成。请善意的指导,如果有人有任何想法。
如果我在行下方添加,则gradle同步失败。
reports.html.enabled = true
2条答案
按热度按时间nwwlzxa71#
您是否在Gradle脚本中添加了以下行?
buildTypes { debug {testCoverageEnabled = TEST_COVERAGE}}
dohp0rv52#
在测试运行器中有一个导出结果选项。一旦测试被执行,你可以将这些结果导出为.html或.xml。这是最右边的选项。
Click here to see where it is