Search code examples
grailsspockgeb

Run all tests in spock


I want to run all spock specs in the given directory sharing the same driver instance. Also I want to keep running all the test even if some tests fail and generate a html report. With cucumber it was easy to do by just running cucumber in the given directory. How to do it with spock. I am using geb with spock for grails application's functional testing


Solution

  • If your build.gradle file contains something like this:

    task test(overwrite: true, dependsOn: drivers.collect { tasks["${it}Test"] })
    

    then, to run the tests use the following commands:

    gradlew chromeTest
    gradlew firefoxTest
    

    To run the tests for all the browsers, you can run the following command:

    gradlew test
    

    This should continue running even one of the test fails and when it will finish, gradle will provide you the location for the html report.