Headless integration tests of an eclipse plugin with maven tycho - junit

I wrote some Junit tests for my eclipse plugin. If I start my test suite as a "JUnit Plug-in Test" from Eclipse, everything is working fine.
Now I want to run them from Maven Tycho.
So I put the following packaging : "eclipse-test-plugin", in the pom.xml and the integration tests start with a "mvn clean integration-test". So I think my maven configuration is quite OK.
But some tests are failing, and I suspect the headless build can't detect the IMarkers my tests are trying to detect, since IMarkers are UI components.
Am I right? Any idea to get my tests based on IMarkers running with Tycho?

You need to tell test plugin that you want to run the test with a UI, by default it will run with the headless runner.
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
</configuration>
</plugin>

Related

Maven run docker image with java ee application

I have a running java ee application which is using wildfly and mysql. Now i heard that docker is using everyone and it is very productive so i decided to dockerize my development environment. Sounds easier than it is.
What i have so far:
Maven for packaging my app into a .war file
Arquillian unit tests which runs the test on my locally installed wildfly instance
What i want:
Using predefined docker images (jboss/wildfly,...) for running my application.
Also running my tests in the docker container.
I started out by building an docker image with the maven-docker-plugin:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>netbeans/sampleapplication</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</configuration>
</plugin>
Dockerfile:
FROM jboss/wildfly
COPY *.war /opt/jboss/wildfly/standalone/deployments/app.war
EXPOSE 8080 9990
Maven command: clean package docker:build.
I can reach the application server just with my docker-maschine url and not like previously with localhost.
In the end i just want to use a single maven command for:
Building the application
Building the docker images (wildfly,mysql...)
Run arquillian junit tests
Deploy the application and expose it via localhost:8080
Stop container if a new deploy is made
I am really struggling with that. Anbody an idea how to do this?
there is no straight forward way of doing this - since some of the docker tasks cannot easily be mapped to a maven phase. So you need to choose what a preferred way of working for you is.
So some thoughts that hopefully will lead to a solution:
The spotify-docker-maven plugin has no mojo's (maven goals) to run an image. Its main tasks are about creating and publishing the docker images.
So to run an image you can simply write some bash scripts (since they will be simple, they will run on linux and even windows using the git bash command line). You could execute those scripts using the maven-exec-plugin.
To properly map that to the maven lifecycle is a bit more tricky.
The phase that matches this the best (my opinion only) is the integration-test phase. This phase has a pre-integration-test phase, the integration-test phase and a post-integration-test phase. The idea is to startup the containers in the pre- phase. Then run the tests in the integration test phase using the failsafe-plugin (not letting the build fail!) and cleaning up the containers in the post- phase. It will be a good idea to cleanup the containers of that project in the pre- phase as well - just in case some zombie containers stick around.
These steps could be put into a profile. Since the integration-test phase is needed for integration tests as well, one would end up executing "maven verify" with different profiles (mvn verify && mvn verify -P docker-tests && mvn -P docker-other-tests).
Another approach would be using the maven plugin created by fabric8.
This plugin is a bit more complicated than the one created by spotify (again: my opinion only). But it comes along with more goals.
Using the provided <packaging>docker</packaging> of the plugin the docker run and stop goals are already mapped to the lifecycle.
Both plugins have in the end a similar complexity in the pom.xml - just its more reading with the fabric plugin. But there are some nice examples and a good user manual.
So those are the two options that came to my mind. Hope this will help :)
Alternatively to directly using a JBoss Wildfly container, you also might check out Wildfly Swarm. It's a separate distribution of Wildfly with even more goodies regarding docker.

Intellij 13.0.2 JUnit test do not run in Debug

Intellij 13.0.2 JUnit test do not run in Debug
I have created several JUnit tests that run fine in Intellij, but when I try to Debug the same test, the files build and the test is not executed. I look in the event log and all it says is All Files are up to date. It does run NMake, but nothing more.
I don't know if this is related, but the View | Tool WIndows | Debug is disabled.
What do I need to do to Debug JUnit tests?
Thanks
Select Run --> Run Configurations... from the IntelliJ window
Select JUnit on the left side.
On the right side there is a "Before Launch:" section for configuring the behavior before launching JUnit tests.
See also the help page for this.

How to integrate Parasoft (JTest) in Hudson?

I normally use JTest Parasoft as a plugin in Eclipse.
But now, I need to integrate JTest in Hudson, at a way that in the Post-build, JTest should run its tests over a Maven project.
So my questions are :
How to integrate JTest in Hudson? I found a plugin CppTest by Parasoft and not JTest...
How to specify the tests which should be run on the project? For example, configure JTest to run "Find unused code" which is included in "Static Analysis"...?
Thank you a lot.
Jtest has fully functional command line interface so generally integration should not be a problem.
As for your questions:
1) there is a Jtest plugin for Maven, so you will be able to trigger your post-build action easily. It's thoroughly described on http://build.parasoft.com .
2) you can specify the Test Configuration of your choice by using -Dparasoft.config option (i.e.: mvn parasoft:jtest -Dparasoft.config="user://Unused Code").
You can find all the parameters which can be used with parasoft:jtest goal described here: http://build.parasoft.com/docs/maven-parasoft-plugin/jtest-mojo.html .
We have integrated Jenkins with Jtest (Linux)
Downloaded the Jtest installers and installed in Jenkins server (in slaves too if you have slaves attached)
Env variables for same has been set (JTEST_HOME)
And now without any entries for Jtest in Pom or build.xml files, we
can directly call the jtestcli commands either in invoke shell
section or use Jtest goals with maven too.
We need to make sure that we have maven-parasoft-plugin 3.12 and Jtest dependencies available in maven repo (for maven projects) and we should have parasoft-ant-3.12.jar available which we need to place in ant lib folder (for ant projects).

Jenkins, xcodebuild -> JUnit-Tests with Appium?

i am using Jenkins CI to build my iOS-Project. For this task, I use a sh-script to build the binaries directly from a git-repo by running xcodebuild and thats working pretty well.
Currently I run JUnit-tests with appium from eclipse to test my app, but I would like to integrate them into Jenkins as well. I found some tutorials to integrate JUnit-tests into jenkins by using ant-scripts, but I dont use ant to build my project.
how can I integrate my JUnit-tests into jenkins, without a ant-script? Or should I use a ant-script?
thank you.
I switched now to Gradle Build Automation which is much easier to handle and can be integrated into Jenkins as well by using Jenkins Gradle Plugin. xCode-Projects can automatically be build from Gradle by using Gradle xcode plugin and its easy to integrate JUnit or NGTests into a Gradle Scripts. In java test classes I am able to use selenium driver against appium server who's remote controlling iOS-Simulator.

Why does the sonar plugin in jenkins build everything again?

I installed Jenkins on my build machine and in the Jenkins config checked the box to run sonar analysis on my maven based project. It works but if I look at the log my entire project is built twice. Once from maven and once for sonar (still using maven). Any idea what I am doing wrong here?
Sonar analysis is performed through a maven plugin. So, whenever you start a sonar analysis, maven will run through all phases that come before the sonar phase, meaning that it will also run the compile and the test phase.
This means, if you want to do a Sonar analysis, you can make a Free-Style Job in Jenkins, configure no Build Step, and only activate the Sonar button. That should work, and should only build your code project once.