how to execute all the invoke top level maven target in jenkins and execute remaining build steps only if maven target are successful - maven

I have a Continuous integration setup using jenkins. I need to run Junit test cases and selenium test cases and commit the jar files in svn, only if all the junit and selenium scripts are passed.
Junit and selenium test cases are separate maven projects so i have used two invoke top level maven targets (One for selenium and other for Junit). I came across following issues,
Selenium scripts will be executed first and if any of the selenium test cases are failed, the jenkins build is marked as Failed and it will start to execute the post-build actions skipping all the build steps including junit. I want to run the Junit test cases also even if selenium scripts are failed. So i have added -Dmaven.test.failure.ignore=true in maven goals to execute the junit test cases even if selenium scripts are failed. This worked perfectly as i expected and continued to execute junit test caes and the build is marked as UNSTABLE.
Now i got another issue, i have a build step to invoke ant at the end (To commit jars in svn only if selenium and junit are passed). After adding -Dmaven.test.failure.ignore=true, the jars are getting commited to svn even if there is any failures.
Can anyone help me to solve this problem?
The build should run both Selenium and Junit, even if there is any failure in any one of project.
Jars should be committed in svn only if everything is successful (This is done by using ant target, so i have placed invoke ant at the end in Build step.
Is there any other way to accomplish this ? Thanks in advance.

Related

How to write a Maven plugin IT test that correctly fails its build, resulting in an overall pass?

When generating a skeleton Maven plugin from archetype, the new project includes a Maven project under the src/it directory. It is an integration it (hinted at by the it dir name) and fresh out-of-the-box it passes when run during Maven's integration-test phase.
There are nearly 10 such IT Maven projects, a subset of which intentionally result in BUILD FAILURE, and attendant verify.groovy scripts that ensure those builds fail for the correct reason. Ideally each IT test sub-build that fails for the correct reason results in that IT test passing, but by including any of these failing IT tests as part of the whole integration test suite causes the overall Maven run to fail as well, which is incorrect in my case.
How do I coax Maven to run those failing Maven sub-builds, ignore their build results, but honor the results of their Groovy verification scripts?
Edit: One IT test (disabled) is committed here.
If you like to write an integration test which is intended to fail as a result
you have to express this via the invoker.properties file like this:
invoker.buildResult=failure
The full description of the file can be found in the documentation.

Running a certain test last using maven

I am using Maven and the failsafe plugin to execute a set of runners that run integration tests.
One of these runners execute tests that involve altering my configuration. For this reason, I would like this runner to be executed only when the other tests have finished executing. Otherwise, there is the possibility of unrepresentative tests.
How can I go about this?
To expand on #khmarbaise comment, in Testng you have annotations that can help you set and reset config files
http://testng.org/doc/documentation-main.html#annotations

Maven is skipping unit tests

I am facing an issue while running test using command line.
mvn test -DskipTests=false -DskipITs=false is only running some unit tests and skipping the rest. Are there any tricks or other options to force maven to take into account all the related tests.

TestLink and Jenkins Test Case not run

I have three test cases in TestLink and when I build the maven project, using Jenkins, none of the tests case is run, the project is built correctly but the test cases aren't run. I am using JUnit for the tests. I am new to this so I am not sure what the problem is.
Thank you.

How can I get maven to continue module builds after reaching surefire forkedProcessTimeoutInSeconds threshhold

In a multi module mvn 3.0 build, I set forkedProcessTimeoutInSeconds to one hour. If tests in module A hang, I hit surefire threshold which will fails the build and skips remaining modules. We use a junit timeouts which should kill hung tests prior to this but some scenarios encounter this problem. I'd like to keep my builds running while I investigate enhancements to our junit runner.
Current Command Line: mvn clean install -Dmaven.test.failure.ignore
How I can change the surefire timeout behavior to move to next module and continue the build?
Does anyone have tips for testing one's junit framework?
I was going to review the surefire project's integration tests for ideas for both items. I plan to have a junitsystest module which activated by a specific profile so I can test various problematic situations outside of my builds.
According to Mastering The Maven Command Line – Managing failures --fail-at-end or --fail-never will provide the desired results. Surefire timeout continues to be reported but doesn't halt the build.
Not recommending in the long run as it lengthens bad build times
mvn clean install -Dmaven.test.failure.ignore --fail-never

Resources