maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Fiedler" <mfied...@wernervas.com>
Subject TestNG from a custom Maven2 MOJO/plugin
Date Tue, 17 Jan 2006 01:42:59 GMT
Hi,

 

   I am writing a custom plugin for determining EMMA code coverage of
TestNG tests.  I am having trouble with the TestNG Test annotation.
TestNG is a dependency (see below).  The TestNG version is 4.0, maven
version is 2.0.1, jdk version is sun jdk1.5.

 

   It feels like a class loader type problem, but
org.testng.annotations.Test is in the testng-4.0-jdk15.jar.  Since the
process was able to invoke the TestNG run method (and other classes), is
this really a class loader issue?

 

Thank you, Michael

 

 

Pom file:

<project>

            <modelVersion>4.0.0</modelVersion>

...

            <dependencies>

                        <dependency>

                                    <groupId>testNG</groupId>

                                    <artifactId>testng</artifactId>

                                    <version>4.0-jdk15</version>

                                    <scope>compile</scope>

                        </dependency>

...

 

 

code snippet:

...

                        TestNG testng = new TestNG(xmlSuite);

                        testng.setTestJar(jarFilename);

                        testng.setSourcePath(srcPath.getAbsolutePath() +
";" + testPath.getAbsolutePath());

 
testng.setOutputDirectory(metadataDir.getAbsolutePath() + "/testNG");

                        testng.setVerbose(1);

                        testng.setGroups("Preferred");

                        testng.run();

                        if(testng.hasFailure() &&
!testng.hasFailureWithinSuccessPercentage()) {

                                    throw new
MojoFailureException("Testing failure occurance is too high!");

                        }

...

 

 

stacktrace:

[INFO]
------------------------------------------------------------------------
----

[ERROR] FATAL ERROR

[INFO]
------------------------------------------------------------------------
----

[INFO] Type org.testng.annotations.Test not present

[INFO]
------------------------------------------------------------------------
----

[INFO] Trace

java.lang.TypeNotPresentException: Type org.testng.annotations.Test not
present

        at
sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreRef
lectionFactory.java:98)

        at
sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.jav
a:107)

        at
sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.j
ava:31)

        at
sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:3
51)

        at
sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser
.java:175)

        at
sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationPars
er.java:69)

        at
sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParse
r.java:52)

        at java.lang.reflect.Method.declaredAnnotations(Method.java:676)

        at
java.lang.reflect.Method.getDeclaredAnnotations(Method.java:669)

        at
java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:
179)

        at
org.testng.internal.jdk15.JDK15AnnotationFinder.findAnnotation(JDK15Anno
tationFinder.java:70)

        at
org.testng.internal.jdk15.JDK15AnnotationFinder.findAnnotation(JDK15Anno
tationFinder.java:92)

        at
org.testng.internal.TestNGClassFinder.isTestNGClass(TestNGClassFinder.ja
va:158)

        at
org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:49)

        at org.testng.TestRunner.initMethods(TestRunner.java:256)

        at org.testng.TestRunner.init(TestRunner.java:192)

        at org.testng.TestRunner.init(TestRunner.java:164)

        at org.testng.TestRunner.<init>(TestRunner.java:112)

        at
org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunne
r.java:325)

        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:160)

        at org.testng.SuiteRunner.run(SuiteRunner.java:126)

        at org.testng.TestNG.run(TestNG.java:292)

        at com.werner.osc.m2plugin.emma.Unit2.test2(Unit2.java:310)

        at com.werner.osc.m2plugin.emma.Unit2.execute(Unit2.java:82)

        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginMa
nager.java:432)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Default
LifecycleExecutor.java:530)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoa
l(DefaultLifecycleExecutor.java:485)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultL
ifecycleExecutor.java:455)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandle
Failures(DefaultLifecycleExecutor.java:303)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
DefaultLifecycleExecutor.java:270)

        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifec
ycleExecutor.java:139)

        at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)

        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)

        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:585)

        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)

        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)

        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Caused by: java.lang.ClassNotFoundException: org.testng.annotations.Test

        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:242)

        at
sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreRef
lectionFactory.java:95)

        ... 41 more

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message