Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Let's imagine a maven project (downloadable here). Unitary tests are placed in the src/test/java folder. You can use mock object as illustrated in the example. When you launch the mvn clean install command, maven compiles your classes and executes the tests. If the tests are executed successfully, the build process continues and creates the bundle as follows:

Code Block
xml
xml
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Dummy Component
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /Users/clement/Documents/workspaces/ipojo-dev/UnitaryTest/target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to /Users/clement/Documents/
        workspaces/ipojo-dev/UnitaryTest/target/classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Compiling 1 source file to /Users/clement/Documents/
        workspaces/ipojo-dev/UnitaryTest/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: /Users/clement/Documents/
        workspaces/ipojo-dev/UnitaryTest/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.apache.felix.ipojo.ut.component.test.MyTestCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.076 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [bundle:bundle]
[INFO] [ipojo:ipojo-bundle {execution: default}]
[INFO] Start bundle manipulation
[INFO] Metadata file : /Users/clement/Documents/
  workspaces/ipojo-dev/UnitaryTest/target/classes/metadata.xml
[INFO] Input Bundle File : /Users/clement/Documents/workspaces/
  ipojo-dev/UnitaryTest/target/org.apache.felix.ipojo.test.dummy.component-1.1.0-SNAPSHOT.jar
[INFO] Bundle manipulation - SUCCESS
[INFO] [install:install]
[INFO] Installing /Users/clement/Documents/workspaces/
  ipojo-dev/UnitaryTest/target/org.apache.felix.ipojo.test.dummy.component-1.1.0-SNAPSHOT.jar 
  to /Users/clement/.m2/repository/ipojo/tests/org.apache.felix.ipojo.test.dummy.component/1.1.0-SNAPSHOT
  /org.apache.felix.ipojo.test.dummy.component-1.1.0-SNAPSHOT.jar
[INFO] [bundle:install]
[INFO] Parsing file:/Users/clement/.m2/repository/repository.xml
[INFO] Installing ipojo/tests/org.apache.felix.ipojo.test.dummy.component/
    1.1.0-SNAPSHOT/org.apache.felix.ipojo.test.dummy.component-1.1.0-SNAPSHOT.jar
[INFO] Writing OBR metadata
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Tue Oct 21 14:03:03 CEST 2008
[INFO] Final Memory: 11M/25M
[INFO] ------------------------------------------------------------------------

...