【问题标题】:How to convert maven surefire into gradle?如何将maven surefire转换为gradle?
【发布时间】:2020-05-02 14:10:12
【问题描述】:

迁移前 我可以在 mvn test -D.. 中设置 -Darguments 。 build 是用 surefire 开始的,但在 Gradle 中我不能这样做

 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.version}</version>
            <configuration>
                <includes>
                    <include>**/RunCucumberIT.java</include>
                    <release>11</release>
                </includes>
                <parallel>methods</parallel>
                <threadCount>${parallel.count}</threadCount>
                <testFailureIgnore>true</testFailureIgnore>
                <argLine>
                    -Xmx2048m
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>

迁移后

    dependencies {
    compile 'org.apache.maven.plugins:maven-surefire-plugin:2.21.0'
    }

    test {
        ignoreFailures = true
        include '**/RunCucumberIT.java'
//option doesn't works
        //options {
            //parallel = "methods"
            //forkCount = 4
        }
    }

我需要并行运行它,而且 -Darguments=someArgument 不起作用

【问题讨论】:

  • 遇到了同样的问题,你有没有找到任何解决这个迁移的方法?

标签: maven gradle maven-surefire-plugin


【解决方案1】:

您需要在 Gradle 任务中设置系统属性。

示例:

task <task_name> {
  systemProperty "arguments", System.getProperty("arguments")
}

现在应用程序可以读取 -Darguments=someArgument

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 2018-06-19
    • 2015-12-13
    • 2015-06-13
    • 2019-06-26
    • 2018-05-16
    相关资源
    最近更新 更多