当前位置: 首页 > 知识库问答 >
问题:

我如何在intelliJ中使用gradle进行cucumber报告?

丁阎宝
2023-03-14

我想要一些非常漂亮的cucumber报告,比如(https://damienfremont.com/2016/05/09/how-to-cucumber-test-report-plugin-2-with-maven-and-java/最后一个cucumber报告)。

但我不能和gradle合作…有人能帮我吗?

这是我的梯度建设...我知道这一定是假的...

    plugins {
        id 'java'
        id "com.github.spacialcircumstances.gradle-cucumber-reporting" version "0.1.2"
    }

    group 'Guru99 Bank'
    version '1.0-SNAPSHOT'

    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
    }

    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.12'
        testCompile 'io.cucumber:cucumber-java:2.4.0'
        testCompile 'io.cucumber:cucumber-junit:2.4.0'
        compileOnly group: 'info.cukes', name: 'gherkin', version: '2.12.2'
        implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.5.3'
        testCompile group: 'net.sourceforge.cobertura', name: 'cobertura', version: '2.1.1'
        compile group: 'io.cucumber', name: 'cucumber-html', version: '0.2.7'
        compileOnly group: 'io.cucumber', name: 'cucumber-jvm-deps', version: '1.0.6'
        compile group: 'net.masterthought', name: 'cucumber-reporting', version: '4.3.0'
        testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
    }

    configurations {
        cucumberRuntime {
            extendsFrom testRuntime
        }
    }

    task cucumber() {
        dependsOn assemble, compileTestJava
        doLast {
            javaexec {
                main = "cucumber.api.cli.Main"
                classpath = configurations.cucumberRuntime + 
   sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 
   'src/test/resources/']
        }
    }

    cucumberReports {
        outputDir = file('path/for/generated/html')
        buildId = '0'
        reports = files('out/cucumber-report.json', 'out/test/cucumber- 
   json.json')
       }
   }

共有1个答案

严宏旷
2023-03-14

在你的 Build.gradle 中试试这个 -

task cucumber(type: JavaExec) {
    dependsOn assemble, compileTestJava
    systemProperty('envcu', System.properties['envcu'] ?: 'dev')
    main = "io.cucumber.core.cli.Main"
    classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
    args = ['--plugin', 'pretty','--plugin','html:CucumberReports','--plugin', 'json:CucumberReports/report.json','--glue', 'CucumberTest', 'src/test/resources']
}

cucumberReports {
    outputDir = file('CucumberReports')
    buildId = '0'
    reports = files('CucumberReports/report.json')
}
 类似资料:
  • 我使用的是commercehub oss/gradle cucumber jvm插件。希望实现自动设置和拆卸的挂钩。就像在junit RunCuketTests中,@BeforeClass和@AfterClass 如何在此插件的自动化中实现这些? https://github.com/commercehub-oss/gradle-cucumber-jvm-plugin

  • 一个简单的问题,即使经过几个小时的尝试和搜索,我也无法弄清楚: 我已经安装了Java6和7。 所有项目模块均设置为使用1.6 设置为 设置未执行任何操作 在命令行中将1.6识别为其JDK 重新启动IntelliJ和/或计算机没有更改行为 是否有一个设置来避免Java1.7被调用?

  • 我是新的IntelliJ IDEA(使用2017.1.3)和gradle... Java文件: 建筑格拉德尔: 当我在Gradle Projects窗口中单击run任务时,我得到以下信息: 我如何设置Gradle或IntelliJ IDEA将主方法中的内容打印到IntelliJ IDEA的控制台视图? 真的不明白为什么控制台视图没有弹出(从IntelliJ IDEA内部,也为什么它没有显示错误是什

  • 我用IntelliJ中的控制台模板创建了一个简单的Kotlin项目,并运行它,我在run-toolwindow中获得了gradle-symbol(参见图片)。 通常我在其他教程中看到有Kotlin符号,所以没有gradle被用来运行Kotlin-Project的主要部分。 是否有可能改变运行Kotlin-main的方式(尽管我查看了运行配置,但没有找到改变“运行环境”的方法) 这更接近,但现在它似

  • 我从Cucumber 1.2.5升级到Cucumber 5.6.0。升级进行得很顺利,但是我的扩展报告坏了。我尝试升级它们并使用Cucumber 4适配器。文件很稀少,我无法让它工作。所以我去下载了示例实现。我能够编译和运行它,并获得报告。我将示例项目升级到Cucumber 4.8.1,将Extent Reporter升级到4,然后运行,但没有创建报告。我不知所措,我的谷歌搜索没有找到任何信息。

  • 我需要在IntelliJ Idea中禁用Gradle守护进程,因为Scala插件无法与该守护进程一起工作(编译失败,出现NullPointerException)。我试图编辑我的IntelliJ Gradle构建配置,以包括JVM系统参数Dorg。格拉德尔。守护进程=false: 我还尝试在同一位置使用标志(脚本参数和VM选项)。我还尝试在