Search code examples
unit-testingmavenjunitosgitycho

Tycho: How to prevent deployment in case of JUnit test failures?


I got an eclipse-plugin with some unit tests.
In maven I kept the unit tests in the same bundle and specified junit as testing dependency in the pom.xml.
Now I want to switch to tycho and I read that tycho is looking for a bundle with the same name plus a postfix ".tests" which gets executed. But I would like to keep my unit tests in the tested bundle so that the build of the bundle will fail if any test fails. Otherwise maven might install/deploy artifacts where the unit tests haven't completed successfully..

Is there a way to keep the unit tests in the same bundle using tycho?
How do you manage unit tests in tycho builds?

Update: Ok I got now two separate bundles an eclipse-plugin and an eclipse-test-plugin. Tycho builds them both in the same reactor but my eclipse-plugin gets deployed although the unit-tests have failed. Now I got a broken artifact in my nexus repo...
Is there a way to enforce a buildfailure when the unit tests didn't complete successfully?


Solution

  • I know this topic is old, but I found such a simple solution. You can configure that the artifacts going to be deployed at the end of the build.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <deployAtEnd>true</deployAtEnd>
                </configuration>
            </plugin>
    

    If you don't ignore failures in your test and if some appears the build fail, no artifacts going to be deployed.