Maven-surefire-plugin

How can I implement below the below from pom.xml in build.gradle?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20</version>
    <configuration>
        <includes>
             <include>test.java</include>
        </includes>
        <systemProperties>            
            <cucumber.options>--plugin junit:target/surefire-reports/cucumber-junit.xml</cucumber.options>
        </systemProperties>
    </configuration>
</plugin>

See Test task documentation

Eg

apply plugin: 'java' 

test {
   systemProperty 'cucumber.options', '--plugin junit:target/surefire-reports/cucumber-junit.xml' 
   include '**/*Test.class'
}

Thank you ! It worked.

Hi Lance, could you please help me to implement the below from Pom.xml to build.gradle

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
      <testFailureIgnore>true</testFailureIgnore>
      <suiteXmlFiles>
        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
      </suiteXmlFiles>
      <properties>
        <property>
          <name>reporter</name>
          <value>
            org.testng.reporters.XMLReporter:generateTestResultAttributes=true,generateGroupsAttribute=true
          </value>
        </property>
      </properties>

    </configuration>
  </plugin>

It’ll be something like

apply plugin: 'java'

test {
  ignoreFailures = true
  useTestNG {
     suiteXmlFiles << file('src/test/resources/testng.xml') 
     listeners << 'org.testng.reporters.XMLReporter:generateTestResultAttributes=true,generateGroupsAttribute=true' 
  } 
} 

See TestNGOptions

Hey Lance, could you please help me to implement the below from Pom.xml to build.gradle

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>

You can just do something like

apply plugin: 'java' 
test.enabled = false 

Hello, thank you very much for your help! I have a problem converting this pom to build.gradle, I don’t know how to do plugin settings.

<?xml version="1.0" encoding="UTF-8"?>


4.0.0
com.appium.example.test
AppiumExampleTest
1.0-SNAPSHOT

<!-- Lista de propiedades -->
<properties>
    <skipTests>true</skipTests>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-project-info-reports-plugin -->
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.9</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/emma-maven-plugin -->
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>emma-maven-plugin</artifactId>
        <version>1.0-alpha-3</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<!-- Plugins -->
<build>
    <plugins>
        <!-- maven-resources-plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <encoding>${project.reporting.outputEncoding}</encoding>
            </configuration>
        </plugin>
        <!-- maven-surefire-plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
                <skipTests>${skipTests}</skipTests>
            </configuration>
        </plugin>
        <!-- maven-compiler-plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <encoding>${project.reporting.outputEncoding}</encoding>
            </configuration>
        </plugin>
        <!-- maven-jar-plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>es.applus.stepdefinitions.com.appium.stepdefinitions.RunCukeTestNG</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <!-- Generates a jar file only with the test classes -->
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>**/**</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- maven-assembly-plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptor>assembly.xml</descriptor>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-3</version>
            <inherited>true</inherited>
        </plugin>
    </plugins>
</reporting>

Hi @Lance Could you please help me to implement below from pom.xml in build.gradle?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <parallel>methods</parallel>
        <useUnlimitedThreads>true</useUnlimitedThreads>
    </configuration>
</plugin>
1 Like

Hi Lance,

Could you please help me to implement below from pom.xml in build.gardle?

org.apache.maven.plugins maven-surefire-plugin 2.22.0 methods true