I have a project that I am usually debugging/running using the grails run-app command. I would like to run a test but without having the server run again only for the specific test.
I usually run the server in debug mode all the time in the background.
I've tried playing around with the run configurations in iteli-j, with latest try being grails test-app functional: className
In Grails 2.4.4 if you override the baseUrl you can run your tests against a server other than localhost. For example, we have a pre-production server hosted on AWS and we run a subset of our functional tests against it from Jenkins, post-deploy, as a smoke test.
grails -plain-output test-app -baseUrl=https://foo.bar.org/ -echoOut -echoErr functional:
That works, but test-app still starts the embedded tomcat server. However, with a bit of digging, I found that overriding the server host to point to a running instance will cause the tests to run without starting the embedded tomcat. There are a couple of ways to accomplish this:
Pass the value on the command line:
grails -plain-output test-app -Dgrails.server.host=foo.bar.org -baseUrl=https://foo.bar.org/ -echoOut -echoErr functional:
Or, overriding the value in Config.groovy for the specific environment should also work:
...
preProd {
...
grails.server.host = 'foo.bar.org'
...
}
...
It isn't documented under test-app, but it is mentioned under run-app and it turns out it works for test-app too.
This works because Grails determines if the embedded server should be started by trying to open a connection to the server host/port, and if successful skips the startup.
From trial and error I have discovered that I have the best results when I specify both grails.server.host and -baseUrl even though the base url becomes redundant information. Possibly this is because my case involves an ssl connection, but I tried running with -https instead of -baseUrl=... and the tests just hung.
This plugin maybe helps you.
Grails functional-test-development Plugin
This plugin aims to make developing functional tests for Grails more convenient by facilitating running your tests against an already running application. It utilises the improved functional testing support added in Grails 1.3.5 and does not work with earlier versions.
Related
I'm running the gradle test task on a Micronaut project and the imbedded server is getting started.
In local that is not much of an issue, but when running the unit tests in the CI environment there isn't a database available for the server to connect to. So ideally we would run the gradle test task without starting the server.
Is it possible to configure Micronaut to not do that?
Is it possible to configure Micronaut to not do that?
Yes. The embedded server is not started by default. It is only started if you write code in your test to start it or if you mark the test with #MicronautTest. If you don't do either of those things, the server shouldn't start.
I have inherited a rails app which has an extensive suite of rspec and cucumber tests, when I run these tests on a CI server such as Circle, I see the tests run (most pass, some fail).
The app connects to a back-office API & I see the code has mocked responses to various API calls, the app also uses elasticsearch.
When I run the test suite locally using bundle exec rspec - I immediacy see a whole bunch of "Elasticsearch::Transport::Transport::Errors::BadRequest" errors from RSpec and failed to connect to those backoffice API's which I mentioned, however none of these failures occur on the CI server (yes, I have tried starting ES locally, same issue)
What am I doing wrong here? How can I run my tests locally to mirror what the CI server is doing to get them to run?
Any help is appreciated! Thank you.
So i'm starting use Intern for functional tests, so far so good I did it all, unit and functional tests.
I followed their intern-tutorial
Whenever you need to run a full test against all platforms, use the test runner. When you are in the process of writing your tests and want to check them for correctness more quickly, you can either use just the Node.js client (for unit tests only) or create an alternate configuration file that only tests against a single local platform, like your local copy of Chrome or Firefox (for all tests, including functional tests).
I searched on their documentation, but I didn't find anything exactly about local "tunnels".
I'm using Intern with Gulp, my localhost is localhost:3000 and I want to test on my Chrome 54 on Mac.
Thank you
I guess NullTunnel is what you're looking for?
I found the answer. I had to change the tunnel to Local Selenium.
Download the latest version of ChromeDriver
Set tunnel to 'NullTunnel'
Run chromedriver --port=4444 --url-base=wd/hub
Set your environments capabilities to [ { browserName: 'chrome' } ]
Run the test runner
Obs:
Don't forget to copy the chromedriver file to your project root.
I had to run on my project root .\chromedriver --port=4444 --url-base=wd/hub
The test runner has to be run in a new command line/terminal/shell
Hope to help someone that had the same issue.
I am using django framework for my project and now I in order to move to continous integration I am planning to use jenkins. natually django-jenkins is the choice.
I am using django unit test framework for unit testing and using patterns finding for testcases discovery.
./manage.py test --patterns="*_test.py"
I have installed and configured django-jenkins and all other necessary modules. Now when I am running the jenking for running the unit test cases, jenkins is not able to discover the test cases.
./manage.py jenkins
Is there some syntax to be followed while naming the unit test files or unit test cases itself?
I also could not find any pattern searching parameter to be used with jenkins.
All options from standard django test runner should works (https://github.com/kmmbvnr/django-jenkins/pull/207) but i'd newer tested them all.
I'm using the example project at https://github.com/geb/geb-example-grails
For some reason, when I run grails test-app functional: it doesn't pick up any tests. It says...
|Loading Grails 2.3.1
|Configuring classpath
.
|Environment set to test
........................................................
|Tests PASSED - view reports in C:\Users\user\src\geb-example-grails\target\test-reports
No browser is opened (what I'm used to with webdriver) and when I view target\test-reports\html\all.html I get...
Unit Test Results - All tests
No tests executed.
I've tried executing with
grails test-app functional:
grails test-app -functional
grails test-app
None appear to run any tests. I've also upgraded the project to grails 2.3.6 with the same result. Am I running the tests incorrectly? Has anyone else had this issue?
Update
I was able to reproduce this problem on my Mac in addition to the Windows 7 machine. When I run on the Mac with...
grails test-app -Dwebdriver.chrome.driver=/Applications/Google\ Chrome.app/Contents/MacOS/chromedriver
Then no tests are run and it reports that all tests pass. (same as the windows machine)
However, when I run via
grails test-app
The tests are run, Google Chrome is launched but no navigation takes place (I suspect I have an outdated chromedriver somewhere in the PATH on the Mac.)
Update 2
After running with...
grails test-app -Dgeb.env=firefox
The tests are found and executed. No nagivation takes place until updating the BuildConfig.groovy with the latest selenium (2.40.0, a webdriver issue I'm familiar with).
With this in mind, I decided to check that the chromedriver was installed properly. While I had placed the chromedriver.exe in the same location as google chrome. I hadn't added that location to my PATH. After doing so... Eureka! Tests run and execute with 100% Passed! Thanks #spikeheap for your suggestion! It appears that tests won't run unless you have the webdriver for your browser setup properly (strange to me, but ok).
I can't reproduce that error. Using 2.3.1 the tests are executed. Have you got the ChromeDriver present? If not I'd expect to see a load of errors...
You could try grails test-app functional: -Dgeb.env=firefox which will attempt to use the FirefoxDriver. If you've got Firefox installed this should work without any additional configuration.
If that doesn't give you anything, try grails test-app functional: PersonCRUDSpec, which will explicitly try to run that test.