0

In Grails 3.1.4: If I use the Grails create-functional-test command and create a Geb test, when I use the Gradle test task it does not run the Geb test, it only runs the unit and integration tests, not the functional.

If I use the Grails test-app command it runs everything. I want to build with Gradle on my Bamboo 5.9.7 integration server.

How do I use Gradle to run all tests, unit, integration, and functional Geb tests?

DAC
  • 707
  • 1
  • 6
  • 20

2 Answers2

3

The test task is only supposed to run the unit tests. You probably want to run integrationTest or iT for short.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • integrationTest is not a gradle task. Is that supposed to be a parameter passed to the test task? – DAC Mar 30 '16 at 21:24
  • 1
    @DAC "integrationTest is not a gradle task." - Yes, it is. It is defined at https://github.com/grails/grails-core/blob/43435e81400073469891a42847fe00793b743ce8/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/IntegrationTestGradlePlugin.groovy#L61 – Jeff Scott Brown Mar 30 '16 at 21:43
  • Clone the project at https://github.com/jeffbrown/testfordac and run `./gradlew integrationTest` or `./gradlew iT`. – Jeff Scott Brown Mar 30 '16 at 21:56
  • Oh, got it! Running gradlew integrationTest works! Sorry, I had tried gradle integrationTest which did not work. Awesome. Thank you very much. – DAC Mar 30 '16 at 22:28
  • `integrationTest` also works with `gradle`, not just `gradlew`. – Jeff Scott Brown Mar 31 '16 at 01:11
  • Sorry, my mistake, integrationTest is a gradle task. It just wasn't showing up in my IntelliJ 15.0.4 IDE for some reason. But if I run it at the command line, it does indeed work. – DAC Mar 31 '16 at 16:24
  • There are other differences between grails2 and grails3. 'grails test-app' will only run the integration tests if ALL the unit tests pass. Also, running the tests a 2nd time without making a code change will run the unit tests, but skip the integration tests, and report the old test data. – burns Jul 11 '16 at 21:11
  • @burns I don't think any of this directly relates to `grails test-app`. I think the question is about how to run tests with Gradle. – Jeff Scott Brown Jul 11 '16 at 21:17
  • Good point @JeffScottBrown. I've offered an alternate answer that tries to warn about some of the grails2/3 differences will also addressing the original question. And I'm glad I saw this post. I didn't know `iT` was a valid replacement for `integrationTest` – burns Jul 11 '16 at 21:46
  • @burns "I didn't know iT was a valid replacement for integrationTest" - Right. Gradle allows you to abbreviate any camel cased task like that. You can also abbreviate by typing the minimum number of letters it takes to make the task name unambiguous. For example, you could invoke the `schemaExport` task with `./gradlew sc` as long as there are no other tasks in your project that begin with `sc*`. – Jeff Scott Brown Jul 12 '16 at 15:39
0

In order to get grails3 gradle tests to mimic the way that grails test-app works in grails2 you might try using

gradlew --continue test iT

This will cause both unit and integration tests to run. Without the --continue option, if you have a failing unit test the integration tests will not execute.

Unfortunately I don't see how to add the "--continue" option to gradle commands when running from intellij.

burns
  • 1,091
  • 13
  • 15