Why don't any of my rspec or cucumber tests run locally? - ruby-on-rails-4

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.

Related

Is it possible to stop the imbedded server from starting when running the unit tests?

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.

Jacoco integration test of API code coverage

Does Jacoco provide code coverage for integration tests of APIs? That is, I have an instance of my application running locally and I have integration tests where I hit an api offered by my running application instance. In this scenario can I use Jacoco to get how many lines of my running application instance was covered when integration tests where ran?
I have already tried Jacoco's maven plugin's prepare-agent-integration and report-integration goals. But they give code coverage as 0. I think its because jacoco only measures code coverage of the currently ran instance and not the instance whose api is hit.
I had forgot to run the javaagent while running the service. Running the jar file with javaagent with output=tcpserver and then dumping the execution file using Jacoco:dump and creating report using Jacoco:report solved the issue.
java -javaagent:<path_to_agent>/org.jacoco.agent-0.7.9-runtime.jar=output=tcpserver,address=127.0.0.1 -jar myapp.jar
mvn clean verify -Pintegration-tests
mvn jacoco:report -DdataFile=./target/jacoco.exec
mvn jacoco:dump -Djacoco.address=localhost -Djacoco.destFile=./service/target/jacoco.exec

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.

Can I run my Ember CLI tests in the browser on my Jenkins CI server?

I'm trying to get my CI server to run my ember-cli test suite. By default, ember test runs the tests using PhantomJS.
Is it possible to have the command use qunit instead, pop open a browser, and return with the appropriate status code?

Test cases discovery using django-jenkins

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.