In some other testing frameworks I'm used to tagging tests, eg #really_slow, #front_end
And then running different batches of tests, like I might want to set up a build slave to run all the really_slow tests, and might want to run all the tests tagged as front end but none that are marked as really slow.
To run my spock+geb tests in grails at the moment I just run grails test-app functional:
How do I tell it to run a subset?
You could use JUnit suites with #Category. Or you could use a SpockConfig.groovy with the following contents:
runner {
include foo.bar.FrontEnd, foo.bar.BackEnd
exclude foo.bar.Slow
}
Here, foo.bar.FrontEnd, foo.bar.BackEnd, and foo.bar.Slow are your own annotations. To activate the configuration file, you have to set a spock.configuration system property pointing to it.
Related
I was trying to run a single test or a single class from the grails cli, but no matter what I tried I am unable to find out how to do that. Does anyone of you have an idea what could be the command for doing that?
What I tried so far
test-app -integration -Dtest.single=package.ClassSpec: still runs all of the tests. Replacing package with a wildcard doesnt change anything.
test-app *ClassSpec* -integration: runs 10 actionable tasks, not entirely sure which tests are these, the class doesnt have 10 tests.
I am using Grails 3.3.2
./grailsw test-app MyClass
(without Spec or Test at the end)
http://docs.grails.org/3.1.1/ref/Command%20Line/test-app.html
I have a simple application with some tests.
Actually, there is 1 JUnit test and some Specifications.
The thing is that when I run each of them separately they work fine.
But when I run:
grails test-app
It's not executing all the tests. All the tests are unit tests but they are in separate packages. But even into the package from the one it's executing, there is another test almost equal, but this one is not being executed as well...
Running grails test-app -unit I get the same problem.
Someone know if I need to do something else to be able to execute them all executing the grails test-app command?
Hm my previous answer was deleted for some reason, but be sure that the Spock test ends with Spec, rather than Test. If it ends with Test, then it will not be picked up.
e.g. MyTest -> MySpec
I am using Spock plug-in in my grails-2.3.4 application for automated unit and integration tests. When I run grails test-app, all the test cases run two times. Also in test report, every spec file is listed twice. As the application grew, number of test cases also grew, and all of them run twice. This takes double time to execute all of the test cases while development and deploying through Jenkins. Can anyone help me fix it (any help will be appreciated)?
http://grails.github.io/grails-doc/2.3.4/guide/upgradingFromPreviousVersionsOfGrails.html -> Spock included by default
You no longer need to add the Spock plugin to your projects. Simply
create Spock specifications as before and they will be run as unit
tests. In fact, don't install the Spock plugin, otherwise your
specifications will run twice [...].
I use selenium WebDriver with junit, ant and jenkins.
I set up jenkins to use ant build.xml to run my tests. But currently I run only one tests. In build.xml I set variable which is used in each test. So to run test in Jenkins I set in Targets:
build MyTest1 -Dvariable="value"
I want to run all tests in sequence one after another. I try this:
build MyTest1 -Dvariable="value" MyTest2 -Dvariable="value"
But 2 tests began run in browser at the same time. How can I organize needed sequence. Maybe there are some ways to do it in build.xml? I guess I can create target, in which call targets which runs tests, but how set my variable in that case? I'm new to ant so please advice me solution.
I need to clarify - my tests are independent, I won't run them in some stable sequence. The problem is that tests are running in parallel in browser. I need to run first test and only after it finish - run second test.
First of all, tests should have little dependencies. In your case, your tests depend on a global variable - try to get rid of it. Use a "configuration" object that you can modify from tests in a safe way and which your application code then uses to configure itself.
Which reduces the problem above to "how do I collect a number of tests" to which the answer is: Use a test suite:
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
#RunWith(Suite.class)
#Suite.SuiteClasses({
MyTest1.class,
MyTest2.class
})
public class JunitTestSuite {
}
In my grails application I use Spock and Geb to perform functional tests.
Since all test run on the same database, I would like to provide order in which CRUDSpec classes being executed. How this can be specified?
Example
First class tests blog author creation
Second class, assuming first test run successfully, tests post creation
Third class adds comments to the post
It turned out that order can be specified as follows:
grails -Dserver.port=8090 test-app functional: LoginCRUDSpec,PayeeCRUDSpec
Another example using packages from here:
// Run all tests in the “admin” package
grails test-app functional: admin.**.*
// Run all tests in the “cart” package
grails test-app functional: cart.**.*
The ultimate way to order tests with no-arg 'grails test-app' is to name test classes alphabetically.
T001_LoginCRUDSpec
T002_PayeeCRUDSpec
T003_ServiceCRUDSpec
T004_DescrParamCRUDSpec