# Test - from maven to gradle

**URL:** https://discuss.gradle.org/t/test-from-maven-to-gradle/14031
**Category:** Help/Discuss
**Created:** [January 29, 2016, 9:27am UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031 "2016-01-29T09:27:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![saulgiordani](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/saulgiordani/32/4181_2.png) [@saulgiordani](https://discuss.gradle.org/u/saulgiordani)
#### Post date: [January 29, 2016, 9:27am UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031/1 "2016-01-29T09:27:06Z")

</div>

Hello,

I’m trying to migrate some integration test from maven to gradle, and I’ve a few questions.

After reading the gradle documentation, I transformed this

```
<profile>
      <id>integration-tests</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.13</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <forkMode>always</forkMode>
              <argLine>-Xmx1024m -XX:MaxPermSize=512m -XX:-UseSplitVerifier</argLine>
              <includes>
                <include>**/*IntegrationTest.java</include>
              </includes>
              <excludes>
                <exclude>com/.../test/*IntegrationTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>7.5.2.v20111006</version>
            <configuration>
              <webAppConfig>
                <contextPath>/xsa-pom</contextPath>
              </webAppConfig>
              <scanIntervalSeconds>10</scanIntervalSeconds>
              <stopKey>foo</stopKey>
              <systemProperties>
                <systemProperty>
                  <name>jetty.port</name>
                  <value>9099</value>
                </systemProperty>
              </systemProperties>
              <stopPort>9090</stopPort>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>ch.finnova</groupId>
          <artifactId>edbs6</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>cronto</groupId>
          <artifactId>crontoengine</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </profile>

```

to this (inside subproject{})

```
test {
		useJUnit()

		// show standard out and standard error of the test JVM(s) on the console
		testLogging.showStandardStreams = true

		// explicitly include or exclude tests
		include '**/*IntegrationTest.java'
		exclude 'com/.../test/*IntegrationTest.java'

		// set heap size for the test JVM(s)
		minHeapSize = "Xms256m"
		maxHeapSize = "Xmx768m"

		// set JVM arguments for the test JVM(s)
		jvmArgs '-Xmx1024m', '-XX:MaxPermSize=512m', '-XX:-UseSplitVerifier'

		// listen to events in the test execution lifecycle
		beforeTest { descriptor ->
			logger.lifecycle("Running test: " + descriptor)
		}

		// listen to standard out and standard error of the test JVM(s)
		onOutput { descriptor, event ->
			logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
		}
	}

```

Is it correct?

I receive compilation errors like

`required: Class<? extends Runner> found: Class<SpringJUnit4ClassRunner>`

But I don’t understand if it is related to some error in the gradle script or not. I think yes because with maven the tests run fine

Thank you very much

---

<div class="post-metadata">

### Author: ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://discuss.gradle.org/u/kris)
#### Post date: [January 29, 2016, 9:35am UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031/2 "2016-01-29T09:35:22Z")

</div>

Looks like you are missing a dependency. IMO Gradle tries to use something which is built in. Did you added all dependencies from Maven to Gradle when migrated?

Note: Gradle comes with some libraries which can conflict with your dependencies if are older/newer. I will advise you to use either -d or -S to detect the problem in your script.

---

<div class="post-metadata">

### Author: ![saulgiordani](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/saulgiordani/32/4181_2.png) [@saulgiordani](https://discuss.gradle.org/u/saulgiordani)
#### Post date: [January 29, 2016, 12:32pm UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031/3 "2016-01-29T12:32:46Z")

</div>

Is there a way to add dependencies to the test and not to the rest of the projects?

In the subproject’s build file I have the testCompile: “…” and I thought it was enough

---

<div class="post-metadata">

### Author: ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://discuss.gradle.org/u/kris)
#### Post date: [January 29, 2016, 2:41pm UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031/4 "2016-01-29T14:41:22Z")

</div>

**testCompile** and **testRuntime** is what you are looking for. If you are in multi-project setup divide configurations per project. Place them only where tests are.

**subprojects** is wrapping all sub-projects (described in settings.gradle). I think is not good idea to place “global” dependency there.

---

<div class="post-metadata">

### Author: ![saulgiordani](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/saulgiordani/32/4181_2.png) [@saulgiordani](https://discuss.gradle.org/u/saulgiordani)
#### Post date: [January 29, 2016, 3:37pm UTC](https://discuss.gradle.org/t/test-from-maven-to-gradle/14031/5 "2016-01-29T15:37:05Z")

</div>

Ok, I was doing exactly the same thing and it works 🙂
