How can I specify test environment for specific Spock test other than default one?
As you can use the spock framework via command like (http://grails.org/plugin/spock, see Running Tests section), like this:
grails test-app :spock
you should be able to specify the environment as well, pretty much like this:
grails [environment]* test-app :spock
because the test-app script allows environment option.
Let me know if this works for you. :)
EDIT:
As you noticed me, the solution above applies for every test in your application. In order to annotate every single test for a specific environment, I think you should have a look at this plugin:
http://www.grails.org/plugin/spock-grails-env-extensions
Thank you. This exactly what I was looking for. Unfortunately current
version of plugin doesn't work with Spock v0.6 =( – fedor.belov Aug 22
'12 at 10:52
It works, you just have to comment dependsOn out (using Spock v0.7).
https://github.com/osoco/grails-spock-env-extensions/blob/master/SpockGrailsEnvExtensionsGrailsPlugin.groovy
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 was wondering whether it is possible in grails to run the integration tests for a single controller. For running all integration tests, i use
grails test-app -integration
how do i run the integration test for 1 controller whose name is SurveyController.
I appreciate any help! Thanks!
Hi please specify the full path of the integration test(copy the reference of it) class as below..
grails test-app -integration path_to_integration_test.SurveyControllerIntegrationSpec
Note: Specify the test class name not controller name.
It should work
grails test-app integration: SurveyController
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.
I have read the documentation for Grails and Webtest in this site:
http://www.grails.org/plugin/webtest
And it's very unupdated. Most of the scripts listed there doesn't work.
I am looking a way to run a working alternative of -nostart listed there.
This is because it's very slow to rerun tests. Or maybe a way to run webtests from outside of Grails
Can you give me any pointer?
Thanks in advance
The webtest plugin changed from version 1.3 to use the new hooks provided by the grails test-app script. Unfortunately one piece of functionality not provided by test-app is the -nostart option.
You could try using
grails interactive
then
test-app -functional
hitting enter should re-run the functional tests without doing a complete restart of grails.
I've also removed the -nostart option from the documentation. All the other documentation should be up to date. What other scripts did not work?
You can raise issues here: http://jira.codehaus.org/browse/GRAILSPLUGINS/component/12994
So, we have a grails app set up with a Hudson CI build process. We're running unit tests, integration tests, and about to set up Selenium for some functional tests as well.
However, are there any good ways of fully testing a sites links to make sure nothing has broken in a release.
I know there's link checkers in general, but I'd like to have it be a part of the build process, so a build outright fails if something isn't right.
WebTest has a verifyLinks step you could use: http://webtest.canoo.com/webtest/manual/verifyLinks.html
You could install the webtest plugin (it should play nice with Selenium) and just have a single test that checks links.
cheers
Lee
I'm using selenium plugin (http://wiki.hudson-ci.org/display/HUDSON/Seleniumhq+Plugin) with test recorded from both developers and functional people. We start the new instance of the Grails app from the Hudson build with the Postbuild (http://wiki.hudson-ci.org/display/HUDSON/Groovy+Postbuild+Plugin)
What we ended up using was a command line program called linkchecker that we could install by apt-get and we ran from within our build script.