Howto integrate jruby integration tests into a maven build? - java

Currently I work on a java web application that is build with maven 3. The integration tests for the application are written in ruby using minitest and capybara. Currently I use c-ruby and bundler to run the tests. For Jenkins integration we use the ci_reporter gem and a rake task.
I want to integrate the testing with the maven lifecycle. For this I use the cargo-maven2-plugin to start and stop an application server in the pre-integration-test and post-integration-test phase. What i am trying to achieve is to run the ruby integration tests in the integration-test phase.
What is the best way to add dependencies? Is it possible to use bundler?
How to start the tests using jruby?

Related

Can I add Jmeter to the project that use Gradle Java and Junit 5?

I have an Automation test project with an API test included.
I use for that JUnit, Retrofit2, Java, and Gradle.
I want to integrate Jmeter to those tests and run performance testing using those tests. It is possible?
Can I (for example) package all of those tests to the jar, and run it using plugin before running the tests?
I saw some topics on the stack overflow and other forums, but it was for Maven and Junit.

How to run maven test with mysql running in docker (using maven-surefire-plugin)

I found several post that explains how to run integration tests wising maven and docker. They basically explains hoy to use/setup fabric8 maven-docker-plugin and maven failsafe plugin.
I'm wondering if is possible to use fabric8, for example, with surefire. My specific need is: I need to run my tests (JUnit tests) but first I need/want to start a docker image with MySQL running on it.
I'm not tied to fabric8. If there is another way to start the docker image before start my tests and stop/kill it once tests run finish, that will help me a lot.
Thanks in advance.
Maxi
Yes you can definitely do that. The idea is to use a maven docker plugin such as fabric8 docker plugin and start a container before the test phases and stop it after the test phase.
But note that technically tests that connect to databases are not unit tests, they should be integration tests.
There are many tutorials online to do that such as INTEGRATION TESTING WITH DOCKER AND MAVEN
You can adapt this for unit tests by just changing the phases when the docker plugin runs.
You can change <phase>pre-integration-test</phase> to a phase that starts before the maven test phase such as <phase>generate-test-resources</phase> and stop the container once the test ends for example:
<phase>prepare-package</phase>.
Note that there are no nice phase names as there are for integration test, as it is not ideal to start external services when running unit tests. But anyway it works.
For a complete reference on maven phases check Introduction to the Build Lifecycle

Integration test after deploy with fail-safe plugin

How would you run integration test separately after deploy is done.
In jenkins we will build, unit test, run some kind of embedded integration tests.
Then it will deploy to remote server.
How can I run Integration tests against remote deployed server? Running same fail-safe plugin will build the application again. The test will be rest-assured java based tests. How to invoke them without rebuilding the app?
Is the only way to somehow play with profiles? Profile for build and test and profile for black box integration(skiping unit tests and embedded integration test)
Maybe I can bind to maven validate phase, which will skip compilation with profile activating "black-box" fail-safe execution(for validation phase only)

Apache Maven - deploying to Karaf and running SOAP UI tests

I have a question regarding test automation with Apache Maven.
Is it possible to configure Apache Maven to run Unit Tests, then package the Java Project as an OSGI Bundle, deploy it to a Karaf OSGI Container and finally run SOAP UI Tests on it (Cleaning the bundle from the Container is not that important but if someone knows how to do this aswell, I'd be happy to hear about this ;) ).
I know that unit testing, packaging and SOAP UI testing itself is not the problem. But how do I get Maven to execute the steps in the order as described (and especially how can I tell Maven to deploy a bundle to an OSGI Container)?
Greetings,
Pascal
This sound more like an integration test.
If you instrument the OSGI deployment and the running of SoapUI tests via java code, then from the maven perspective it is very simple.
Is this a workable solution for you?
Just set up integration tests via a maven profile and run tests as normal: mvn clean test -Pintegrationtests

Pointers on how to to get a test jar to run a separate war for testing (perhaps with cargo?)

Let me explain some of my constraints.
We have a war that has a CXF Soap service and a Spring MVC REST Service. Both the CXF and Spring MVC implementations are in a separate jar and are brought in as dependencies. The REST service has its unit tests in its project.
I was wondering if there was any way to, while doing something like 'mvn clean test' in the REST jar, to have a local version of the war set up and then run the unit tests. Thus, when building in something like Hudson or doing releases, there won't have to be any workarounds (such as deploying a snapshot ear or running a local war manually)? I've seen this done when the tests are within the war using cargo, but not when the tests are separate from the war.
Right now, we're going to take the tests out into a separate jar but that's still not ideal as if something happens to go wrong during a release, that'd mean the REST jar and war were already released. I'd prefer do it the above way, with the tests in the same project as the REST service.
If anyone has any pointers or doc or examples that could help with this, it would be appreciated.
Honestly, I'm not sure I understood all the constraints. Anyway, the recommended way to implement integration tests with Maven is to put them in a separate module (that's much easier, especially if the module under test also have unit tests) that depends on the war/ear under test and to:
Start a container and deploy the war/ear during the pre-integration-test phase
Have Maven run the tests during integration-test
Stop the container during post-integration-test
For the steps #1 and #3, I personally use Cargo. For the step #2, using the Maven Failsafe Plugin is the preferred option (because it won't stop the build if a test fail). At least, this is what I use and I have used the resources below to build my setup.
An alternative approach would be to start/stop an embedded container from the tests. For example, this is doable with Jetty, see Embedding Jetty and Unit Test Servlets with Jetty.
Resources
Functional testing with Maven, Cargo and Selenium
Maven and Integration Testing
Maven and Selenium
Unit Test Servlets with Jetty
Maven has also integration-test phase. Use maven-jetty-plugin to start container and deploy application. Then run your integration test.
Maven Jetty Plugin
Maven and Integration Testing
Update
Tests cannot be in a jar file. Maven surefire plugin could not run them. The tests are part of the project where you run integration test. The tested war file can be set as dependency library. It will be downloaded, deployed and the you run integration tests.

Categories

Resources