I'm finding the feedback look pretty slow when running integration and functional tests in Grails. Is there a way I can run them against a running server instance while I'm writing the tests, to save on server startup time each time they're executed?
You can use grails interactive which does what you want without starting a server. It starts a JVM and keeps it running and you can use it to run unit and integration tests. Keep in mind that you'll eventually run out of memory and need to restart periodically. See http://docs.grails.org/latest/guide/gettingStarted.html#usingInteractiveMode
Also in 1.3.5 you can run functional tests against a running server. Use the baseUrl attribute described in section 9.3 at http://grails.org/doc/latest/
there's an option --baseUrl
e.g.
grails test-app --baseUrl=http://localhost:8080/myapp/
that runs tests against a running instance, one draw back is that the slate isn't wiped clean after a test, so if your test writes to the db, uploads a file, or some other permanent change to the application, then you may have to do some tearDown.
This is briefly documented at the end of the function testing section of the grails docs
http://grails.org/doc/latest/guide/testing.html#functionalTesting
It's useful for writing/debugging functional tests
I'm using Grails 1.3.5 and the EasyB plugin for stories in the context of functional tests.
Take a look at http://padcom13.blogspot.com/2010/10/grails-easyb-and-selenium.html for step-by-step instructions.
Related
Currently, I have an automation framework that consists of the following stack:
Python
Pytest Framework (and pytest-xdist parallel mechanized)
Selenium
Allure report system
Jenkins
I'm going to add a docker containerization system as well, to run tests using it on a windows server.
I'm running my tests using pytest's internal parallel run (pytest-xdist) functionality using 'workers'
the run command looks like this:
os.system("pytest -v -s --alluredir="'C:\AllureReports\Data'" --html=report.html --developer=dmitriy --timeout=60 --self-contained-html --dist=loadfile -n=3 -m=regression")
As you can see '-n=3' is the number of 'nodes' that the suite will be executed. In other words, the regression suite will run in a parallel run of 3 nodes.
Can you tell me if it is possible to avoid using Selenium-Grid mechanized, and use this pytest's internal parallel run system instead -> pytest-xdist, and how?
Will appreciate relevant technical articles or explanations of how it can be done.
I have gone over this question - pytest-xdist vs selenium hub
but got only a really overview impression which is not enough
My application runs properly using Faye, Redis, Resque and other services, that I am starting every time with Foreman. Now I am writing acceptance tests with Capybara+RSpec, and I wonder how I could start Foreman (or even Faye alone) with Capybara in spec_helper to test live features.
One option is to not depend on these services in your tests. I know redis and resque have "mock" counterparts that behave like these services without actually needing to run them. Some services might not have a "mock" version (I can't find one for Faye), so you may just need to run them in the background.
if you are using jenkins as the CI server, you can start the foreman before rspec started.
I've started learning to use Ruby on Rails running on Windows 7, and the time to run tests is painful I'm wondering if I can speed it up.
Right now I am using the default test framework (inheriting from ActionController), with a SQLite database and the webrick web server.
While unit and functional tests report a runtime of less than 2 seconds, from the time I run the tests from the command-line to completion is actually 40 secounds.
A friend recommended I use guard. That looks like it will help start the tests as soon as I save, but it seems like the real cost is starting up the webserver or database. I wonder if it might be better to set up apache or mysql and use those locally instead.
Anyhow, what tips do people have for speeding up ruby on rails tests on windows? I tried running the tests on Amazon EC2 linux micro instance (again with webrick and sqlite) and there was significant startup time (though I did not time it).
I tried "rake test --trace". There was a significant pause:
Immediately before the first line of output
Between outputing "Execute environment" and "Execute db:abort_if_pending_migrations"
Between "Execute test:units" and "Run options:"
The first pause seems worse.
Your best bet is to use spork which now works in Windows. It runs on windows by pre-populating a pool of ready processes (referred to as the “magazine” strategy). The result is that webserver startup time is dramatically reduced.
If running rails on Windows is really the bottleneck then you can run a virtual machine using VirtualBox and run an instance of Ubuntu and work on your rails projects in the VM.
I want to have a automatic deployment of my test system on every night to the dev#cloud system of cloudbees.
The problem is now that I use the dbm-update goal on grails and its trying to update the database from Jenkins. This is a problem because the com.cloudbees.jdbc.Driver is not available in this context. Only if the app is deployed to the test sytem.
Does somebody tried this already and can help me out with some tips how to solve or workaround this problem?
Thanks
You can set the updateOnStart flags in the plugin for your application in the test context,
grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
This will run the migrations when your test application starts, making you not need to do a separate dbm-update. Since this uses the same JDBC drivers as your running application, it should work.
Look at the RUN console (https://run.cloudbees.com) - there you will find your MySQL settings
You can just use a standard MySQL JDBC driver to connect to the MySQL database from anywhere (including from DEV#cloud and your test cases).
I am working with the webtest plugin as functional test component for grails.
It works fine, but is very slow - the whole application has poor response times (>1min per page) when under test. My feeling is that this is because the app, canoo webtest and the IDE (netbeans) are running in one JVM when I start my test through the IDE (test-app functional:)
So my goal is now to deploy the app to a stand-alone tomcat and run my tests against this tomcat instance.
I googled and found an old option -nostart for webtest which seem to be outdated.
So I googled some more and found the -baseUrl=http://... option in the current documentation. The docs say that with this option, the app will not be started and all tests will run against this baseUrl. But when I give it a try, grails still tries to start up jetty (at least, I get an error message saying that the port 8080 is already in use).
Any ideas? I am already thinking about using webtest stand-alone, but I like the groovy syntax of the plugin...
I'm using grails 1.3.4
You could try interactive mode as mentioned here: Can I run grails integration & functional tests against a running server?
If the -baseUrl option isn't working then I'd raise a JIRA issue.
cheers
Lee