grails doesn't find geb functional tests - unit-testing

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.

Related

TeamCity - run all unit tests - maven

I am very new to TeamCity and I was asked to upgrade JUnit to the newest version in our project. During my upgrade I had to update some tests, because JUnit API has changed. Now I would like to run all the tests, to be sure that I haven't damaged anything. We have set up CI using TeamCity, where all the tests should be run during the build, but what is happening is that only one test is triggered (normally it is over 200). I am not sure if it is because I have changed only the unit tests and there was no change in the code, but I would like to force trigger all the tests. Could someone please help me to achieve this. Thanks a lot.

How can I run Django unit test in Microsoft TFS automatically?

How can I run django unit test in Microsoft TFS automatically?
By default the Python-Django test feature is not integrated in TFS.
However vNext build (TFS 2015 and later) have more flexible steps, so you can use the Command line task or Utility: Batch script task to run pytest or django test. That means if you can run the Django unit test in command line, then you can run the tests in TFS.
Please reference this article to do that: Running Python Unit Test in a VSTS/TFS build
Other articles for your reference to run the Django unit test:
Writing and running tests
DJANGO UNIT TEST CASES WITH FORMS AND VIEWS
Setting a Full Testing Framework for Django (and more!)
Besides, you can also have a try for this extension : Python Test

NUnit Test Adapter and NUnit both discovering and running tests

I have the NUnit test adapter (3.X) installed and my test project references NUnit (3.8.0.0). However, I'm seeing duplicate tests discovered (during build) and run by the NUnit Adapter 3.8.0.0 and NUnit 1.2.0.0. What could be causing this? I can't work out where NUnit 1.2.0.0 is coming into this.

Why don't any of my rspec or cucumber tests run locally?

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.

Run grails functional test without having embedded tomcat start

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.