2

did someone ever tried to run PaxExam Junit tests with Bndtools and can give me some advices? I've tried it by myself, but without Maven it's a pain to download all the dependencies.

What I've done so far:

  1. Download PaxExam dependencies from Central Maven (are there any more easier ways?)
  2. Create property containing all dependencies in cnf/bnd.bnd
  3. Add property to buildpath where I want to write tests
  4. Executing tests fails, bc more dependencies are missing so back to 1. :D

I want to use PaxExam, bc its easier to use with Ant Junit task as the Integration Test of Bndtools since they only produce test reports but they are not really "Junit Tests".

Later scenario:

  1. Building projects with Hudson and Ant
  2. Hudson should also execute Junit Ant Task where failed tests should stop the building process as well

The above scenario already works with normal Junit4 tests without running an OSGi environment, but now I want to do integretion tests.

Can someone help me?

Greetings.

christian.vogel
  • 2,117
  • 18
  • 22
  • Have you considered simply using Maven with the Maven Bundle Plugin instead of ant+bndtools? It works great for me. – Björn Pollex Aug 01 '12 at 08:51
  • In my opinion Bndtools is way better than MBP since it makes development easier for some cases. So yes I had a look, but decided to go with Bndtools ;) – christian.vogel Aug 01 '12 at 09:13
  • Why are bnd's test reports not 'real' unit tests? – Peter Kriens Aug 02 '13 at 06:39
  • Hi Peter, I can't really give you an answer since I don't remember why I had problems and asked to give me advises for PaxExam. Maybe it was the only possibility I had back then, or I wasn't as experienced as I am right now ;) (It could be that I was missing the socket communication between Bndtools and the JUnit view to produce the output there, not only the console output of "failure" and "success" - but don't remember exactly) :) – christian.vogel Aug 22 '13 at 10:32

1 Answers1

4

Even though you don't use Maven for building your project, you can still use it to download maven-artifacts and their transitive dependencies. To do this, you first have to install Maven. Then, you create an empty directory, and inside that directory, you create a file called pom.xml. For Pax Exam, this should look like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <properties>
        <exam.version>2.5.0</exam.version>
        <url.version>1.4.2</url.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-container-native</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-junit4</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-link-mvn</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
            <version>${url.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <version>3.2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.29</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.29</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

I have taken the list of dependencies from the Pax Exam documentation. Then, you open the command-line, navigate to the directory in which you created your pom.xml, and execute the following command:

mvn dependencies:copy-dependencies

(this assumes that you have installed Maven such that the command mvn is available form the command-line). Now maven will fetch all transitive dependencies of the dependencies you have specified in the pom.xml, and store them in target/dependency by default.

Björn Pollex
  • 75,346
  • 28
  • 201
  • 283
  • Funny story: I already thought about to do it like you described it in your answer ;) So you get +1 from me :) But nethertheless, maybe there are other ways. hopefully – christian.vogel Aug 01 '12 at 09:56
  • I accepted your answer, since it seems that the only way :) So for me it is the most helpful one. Congratulation ;) – christian.vogel Aug 04 '12 at 10:51
  • You could offer a bounty on your question to get more views and encourage people to think harder. – Björn Pollex Aug 05 '12 at 18:58