You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Erik Lindblad <er...@gmail.com> on 2009/09/07 15:30:12 UTC

Regarding mock-classes and surefire junit tests

Hello!

I've wrestling with the following problem for a few days now. I have
created a junit test that uses a mock of the jboss cache mechanism.
The real jboss jars are included in the POM in the provided scope and
the mock classes reside in the test subtree.

So the project setup is something like this:

my-app
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |       `-- com
    |           `-- mycompany
    |               `-- app
    |                   `-- App.java
    `-- test
        `-- java
            `-- com
                `-- mycompany
                    `-- app
                        `-- AppTest.java
            `-- org
                `-- jboss
                    `-- cache
                        `-- TreeCacheMBean.java

However, when I run "mvn clean test", the test fails with a
NoSuchMethodException:
java.lang.NoSuchMethodError:
org.jboss.mx.util.MBeanProxyExt.create(Ljava/lang/Class;Ljava/lang/String;Ljavax/management/MBeanServer;)Ljava/lang/Object;
	at com.mycompany.app.App.foo(App.java:123)
	at com.mycompany.app.AppTest.test1(AppTest.java:123)

However, if I let Eclipse/maven integration build the workspace (I use
project->clean... after which it autobuilds the project) and then run
"mvn test" to compile the test subtree and run the tests everything
works as expected. Any ideas of what I'm doing wrong?

Cheers,
Erik

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org