我有一个 build.gradle 文件,它可以单独或一起成功运行单元和集成测试(使用像 gradle test integrationTest 这样的命令一起运行)。两者都使用 Junit,我使用的是 Gradle 3,这不是 Android 项目。在单独的目录中为每个生成关于成功的报告。我还可以使用 gradle test jacoco 为 unit 测试覆盖率成功生成 Jacoco 报告。我无法通过使用 gradle integrationTest jacoco 获得我的其他工作集成测试的覆盖率报告,尽管测试成功运行并生成了 integrationTest.exec 文件。
更明确地说,我在 build/reports/index.html 中获取单元测试覆盖率报告,在 build/reports/test/index.html 和 build/reports/integrationTest/index.html 中获取 Junit 报告。创建了一个 build/reports/jacoco 目录,但只包含一个空的“test”目录。 build/还包含一个 jacoco/目录,其中包含 .exec 文件和类路径转储。
这是我的缩写 build.gradle
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['src/java']
}
test {
java {
srcDirs = ['test/java']
}
}
resources {
srcDirs = ['src/java', 'conf', 'resource']
}
}
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('integration_test/java')
}
}
}
test {
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
/* SNIP */
task integrationTest(type: Test) {
dependsOn startserver
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
}
integrationTest.finalizedBy stopserver
check.dependsOn integrationTest
integrationTest.mustRunAfter test
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
jacoco {
toolVersion = "0.7.6.201602180812"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "$buildDir/reports"
}
}
我已经看到有关合并两个报告、生成我已有的 Junit 集成测试报告的现有问题,以及关于 Maven 和 Ant 的类似但最终没有帮助的问题。我找到的最接近的是 this ,但我尝试从中改编的任何内容都没有取得成果。似乎确实有一个 similar question ,但他们的 build.gradle 较少,唯一的答复是上一个链接中问题作者的 0 赞成票,未接受的答复。
由于这已经很长了,我不想提供比这里更多的内容,但如果有任何不清楚的地方,我很乐意提供更多内容。
我已经证实,没有发生像单元测试结果覆盖集成测试这样愚蠢的事情——运行集成测试和没有定期测试的 jacoco 甚至不会生成类似的文件。
我可以做些什么来获得集成测试覆盖率?
[第一次编辑] 我创建了一个小型 Github 存储库,其中包含重现此问题所需的一切:https://github.com/micseydel-tile/gradle-jacoco-integration-test
最佳答案
我终于可以通过以下方法获得汇总报告:
根 build.gradle -
subprojects {
apply(plugin: 'org.jetbrains.kotlin.jvm')
repositories {
jcenter()
mavenCentral()
}
}
task codeCoverageReport(type: JacocoReport) {
// Gather execution data from all subprojects
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
// Add all relevant sourcesets from the subprojects
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
}
// always run the tests before generating the report
codeCoverageReport.dependsOn {
subprojects*.test
}
运行gradle codeCoverageReport
关于java - 带有 Jacoco 插件的 build.gradle 不会为集成测试生成覆盖率报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39967911/
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht