Run non-eclipse-junit tests

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Run non-eclipse-junit tests

Andreas Pakulat-3
Hi,

I've just started working with Tycho and Maven, so if you think I'm
asking in the wrong place don't hesitate to direct me elsewhere :)

I'm using Tycho here to build packages for our RCP app. One part of this
application is actually a non-eclipse library that we're also using in
some other projects. This library is bundled into the app by using an
eclipse plugin that builds its sources and a custom buildstep setup in
eclipse to run its unit-tests.

I'd like to do something similar with maven and Tycho. Right now I've
adjusted the sourceDirectory and testSourceDirectory to point to the
sources as they're in a subdirectory. Unfortunately this means that the
test-classes also get bundled into the jar and the final rcp app and no
unit-tests are being run on this either.

Is there a way to accomplish this?

Andreas

--
Andreas Pakulat [hidden email]
froglogic GmbH - Automated UI and Web Testing
Reply | Threaded
Open this post in threaded view
|

Re: Run non-eclipse-junit tests

Andreas Pakulat-3
On 22.05.10 23:31:57, Andreas Pakulat wrote:

> Hi,
>
> I've just started working with Tycho and Maven, so if you think I'm
> asking in the wrong place don't hesitate to direct me elsewhere :)
>
> I'm using Tycho here to build packages for our RCP app. One part of this
> application is actually a non-eclipse library that we're also using in
> some other projects. This library is bundled into the app by using an
> eclipse plugin that builds its sources and a custom buildstep setup in
> eclipse to run its unit-tests.
>
> I'd like to do something similar with maven and Tycho. Right now I've
> adjusted the sourceDirectory and testSourceDirectory to point to the
> sources as they're in a subdirectory. Unfortunately this means that the
> test-classes also get bundled into the jar and the final rcp app and no
> unit-tests are being run on this either.
>
> Is there a way to accomplish this?

The answer is that there is, I just needed to dive a bit more into how
maven works than I did so far. Sorry for posting a
not-really-tycho-related question here.

For those coming after me: My solution is to enable the surefire
plugin's test goal as part of the test phase and also enable the
compiler-plugin for the test-compile phase. Then I just needed to make
the compiler aware of the directory with the test sources. Basically I
just added the following to the generated pom.xml:

,----
|   <build>
|       <testSourceDirectory>library/tests</testSourceDirectory>
|       <plugins>
|           <plugin>
|               <groupId>org.apache.maven.plugins</groupId>
|               <artifactId>maven-surefire-plugin</artifactId>
|               <executions>
|                   <execution>
|                       <id>test</id>
|                       <phase>test</phase>
|                       <configuration>
|                           <includes>
|                               <include>**/*Test.java</include>
|                           </includes>
|                       </configuration>
|                       <goals>
|                           <goal>test</goal>
|                       </goals>
|                   </execution>
|               </executions>
|           </plugin>
|           <plugin>
|               <groupId>org.apache.maven.plugins</groupId>
|               <artifactId>maven-compiler-plugin</artifactId>
|               <executions>
|                   <execution>
|                       <id>compiletests</id>
|                       <phase>test-compile</phase>
|                       <goals>
|                           <goal>testCompile</goal>
|                       </goals>
|                   </execution>
|               </executions>
|           </plugin>
|
|       </plugins>
|   </build>
|   <dependencies>
|       <dependency>
|           <groupId>junit</groupId>
|           <artifactId>junit</artifactId>
|           <version>4.7</version>
|           <scope>test</scope>
|       </dependency>
|   </dependencies>
`----

Andreas

--
Andreas Pakulat [hidden email]
froglogic GmbH - Automated UI and Web Testing