[slf4j-dev] Unit tests in slf4j-ext and Maven

Ceki Gulcu listid at qos.ch
Thu Oct 2 20:57:13 CEST 2008



Thorbjørn Ravn Andersen wrote:

> I'm trying to get unit tests up and running in Maven for the agent, but 
> I am unfamiliar with the Maven way of doing things, so I'd appreciate 
> some comments.
> 
> I've figured out how to use the <argLine> tag to get "-javaagent:foobar" 
> put in the right place of the surefire invocation, but unfortunately it 
> is a hard requirement that the _jar_file is used, and it appears to me 
> that the test-phase is before the jar-file is built, so it is not even 
> available at that time.
> 
> Is there a good way to run unit tests after the jar file is built, and 
> how do I refer to the jar file in pom.xml?  

Hello Thorbjørn,

It is quite difficult to get Maven to do things it is not designed for, at least 
not out of the box. I do not know how to run unit tests after the jar is built. 
Usually, the jar is built, only if the tests pass. (Tests always come before the 
packaging.) For the various Maven2 test phases, see

   http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html

We could run the test after the packaging phase, for example during the 
"integration-test" phase. I'll see what I can do.

On a related note, the addition of 
<argLine>-javaagent:${project.build.outputDirectory}=time</argLine>
seems to cause Continuum to fail. Here is the error message:

  [INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building SLF4J Extensions Module
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /opt/continuum-1.1/working-directory/8/target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 14 source files to 
/opt/continuum-1.1/working-directory/8/target/classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Compiling 10 source files to 
/opt/continuum-1.1/working-directory/8/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: 
/opt/continuum-1.1/working-directory/8/target/surefire-reports
Error occurred during initialization of VM
Error opening zip file: /opt/continuum-1.1/working-directory/8/target/classes
agent library failed to init: instrument
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

I'll look into this some more and get back to you.

> /Thorbjørn

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch



More information about the slf4j-dev mailing list