Performance issue with webtest and grails - grails

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

Related

How to run Spock unit tests without intializing Grails environment

I have a Spock unit test in a Grails app. In IntelliJ IDEa I can either run it with grails environment and then it means I wait a minute until the environment loads to run the test even though I do not need the environment.
The other option is to run it with JUnit. This works nicely in a Grails app without my own plugins. However, when I run it in a Grails app that has a plugin of another Grails app I have, it crashes on NoClassFound. It does not see the classes from the plugin that I included.
When I checked in IDEa the project structure, indeed the sources nowhere include a folder where the plugin classes would be included. For some reason the plugins in plugins section in BuildConfig.groovy do not appear in the classpath anywhere, they are not found in the external libraries section or anywhere else.
Is there a way to tell grails not to spin up its environment when running some of my tests? Or how can I include my plugin in the classpath for Groovyc to see it when building for testing?
The problem occurs also when simply pressing Build Project in IntelliJ IDEa. The project we are working with is simply run with grails and is never built (beyond how grails builds it). When you try to build it in IDEa, it fails on NoClassDefFound of plugin class.
Versions:
IntelliJ IDEa 2021.2
Grails 2.5.6
EDIT: Ok, it seems like grails apps are to be tested via their command-linke with grails test-app. When Grails runs in interactive mode, test-app won't have to reinitialize the environment, cause it's already running, so it runs faster.
However, as I found here Slow Grails test starting in Intellij IDEA it seems like there's no way to run grails in interactive mode from within IDEa in a way that would enable IDEa test runs to use such interactive console. Which means I'm forced to run tests via command-line. Not happy.
Edit 2: At some point in time I have managed to get the compiled tested.class to the out folder. This enabled running the test instantly via IDEa circumventing the Grails glory. However, I have no idea how I got it to out folder and after removing it I am unable to compile it again and get it there.

Grails fails if started with String parameter

I'm pretty new to the Grails Framework and I'm experiencing some strange behavior. If I use the grails commandline tool this way
grails "-DghprbPullTitle=Title with spaces" clean
grails fails with this error message
| Script 'With' not found, did you mean:
1) IntegrateWith
2) Init
3) CreateUnitTest
Starting grails this way will work
grails "-DghprbPullTitle=Title_without_spaces" clean
Ok one can now say "Then just avoid spaces" The problem is, that this occurs while I'm using Jenkins + Grails Plugin + Pull Request Builder Plugin. The Pull Request Builder Plugin generates some of these parameter with whitespaces.
Any thoughts how I can use grails with such whitespace-containing parameter. Or how I can tell the Pull Request Builder Plugin no to generate such parameter.
Maven on the other hand is able to handle such parameter.
Thanks in advance,
Marco
I ended up using shell builder with grailsw call instead of the Grails plugin.
Ok so it was a bug in the grails commandline tool. It will be fixed in grails 2.4-RC1.
See Grails Issue Tracker
The problem is that Grails Plugin + Pull Request Builder Plugin makes it pass build parameters from PR Builder plugin to grails commands. Those arguments with spaces are not required for build to happen, it's some kind of default in Grails Plugin to pass those parameters along to grails commands.
If Grails Wrapper on Grails Plugin didn't work for you, using Shell commands instead of Grails Plugin worked for me: it avoids parameters with space and makes GitHub notifications to work. It's worse for grails installations maintenance, but at least it's an alternative.
I submitted a PR https://github.com/jenkinsci/grails-plugin/pull/12 to work around this by suppressing the -D build environment variables.
I am using the Github pull request builder plugin https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin to run test-app and was running into the same issues as others. I am not using any of the variables that the ghprb plugin passes in so I added an option to suppress -D build environment variables. When this option is checked none of the -D variables are passed to grails allowing the build with grails plugin to run the targets as expected.
If you want to test it out to see if it works for you, you can download it from here http://jmoses.co/data/grails.hpi and install it manually How to install a plugin in Jenkins manually?

Were the generate-* commands removed from Grails 2.3.2?

When I type generate-all, generate-controller or generate-vies, Grails current version (2.3.2) does not recognizes them. However, these commands remains on the Grails documentation. Does anyone knows if these commands were removed (and the docs are not up-to-date)?
Try grails compile first.
These commands are now part of the scaffolding plugin, and you might need to get grails to fetch the plugin

Grails - Link checking as part of a continuous integration

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.

How do you install and use grails test coverage?

I'm trying to get the grails code coverage plugin to work based on these directions:
http://www.grails.org/Test+Code+Coverage+Plugin
I did: grails install-plugin code-coverage
Then: grails test-app
Based on that I expect to see a tests/report/cobertura directory, but I don't see anything inside my project after running "grails test-app".
I've got grails 1.1 installed and created a new application. Do I need to do anything else to see these reports? Are there better instructions anywhere?
Thanks
You must use "grails test-app -coverage" to generate the coverage reports.

Resources