# Creating another type of test task in Java

**URL:** <https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472>\
**Category:** Old Forum Archive\
**Created:** [November 29, 2012, 11:14pm UTC](https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472 "2012-11-29T23:14:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Halperin](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daniel_halperin/32/1006_2.png) [@Daniel\_Halperin](https://discuss.gradle.org/u/Daniel_Halperin)\
**Post date:** [November 29, 2012, 11:14pm UTC](https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472/1 "2012-11-29T23:14:00Z")

</div>

Hi all,

In our project we have both ‘tests’ and ‘speedtests’. The latter are performance tests and take a long time, so we don’t want them running every time we test compiler correctness.

Right now, here’s the sourceSets configuration:

```gradle
sourceSets {
  main.java {
    srcDir 'src'
    srcDir 'protobuf/java'
    srcDir 'third-party-src'
  }
  test.java {
    srcDir 'test'
  }
  speedtest.java {
    srcDir 'speedtest'
  }
}
  task speedtest(type: Test) {
  testClassesDir = sourceSets.speedtest.output.classesDir
  classpath = sourceSets.speedtest.runtimeClasspath
  include = 'speedtest/**'
  scanForTestClasses=true
}

```

If I run ‘gradle build’ it will compile everything successfully and run the tests in the ‘test’ subdirectory. It does not run ‘speedtestClasses’ to compile the ‘speedtest’ code. When I run ‘speedtestClasses’ manually, it fails—presumably because it does not know that, like test, it needs to copy all the settings from ‘compile’ and ‘runtime’ and ‘testCompile’ and ‘testRuntime’.

Is there a way to easily get it to clone ‘test’'s settings and act in a similar way?

Thanks!

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 29, 2012, 11:51pm UTC](https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472/2 "2012-11-29T23:51:00Z")

</div>

For an example on how to set up an additional ‘Test’ task, see ‘samples/java/withIntegrationTests’ in the full Gradle distribution.

---

<div class="post-metadata">

**Author:** ![Daniel\_Halperin](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daniel_halperin/32/1006_2.png) [@Daniel\_Halperin](https://discuss.gradle.org/u/Daniel_Halperin)\
**Post date:** [November 30, 2012, 1:12am UTC](https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472/3 "2012-11-30T01:12:00Z")

</div>

Thanks so much! Is there no way to find this information online? Most users won’t start by cloning the gradle git…

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 30, 2012, 10:39am UTC](https://discuss.gradle.org/t/creating-another-type-of-test-task-in-java/5472/4 "2012-11-30T10:39:00Z")

</div>

You can either download the full distribution, or browse the GitHub repo.
