10 Feb 18:55
testNG framework
From: Chaffangeon Brice <brice.chaffangeon@...>
Subject: testNG framework
Newsgroups: gmane.comp.cms.nuxeo.general
Date: 2007-02-10 17:58:59 GMT
Subject: testNG framework
Newsgroups: gmane.comp.cms.nuxeo.general
Date: 2007-02-10 17:58:59 GMT
Hi all, In order to test our Seam components, I tried to use the testNG framework (http://testng.org/doc/), independently of Nuxeo. The main advantage of testNG rather than jUnit is that Seam extends it to provide a "Seam Ready" framework. There is an eclipse plugin that can be found here (http://testng.org/doc/download.html). It just works as the jUnit plugin. The requirements for using testNG are (at least): - the testNG jar (can be used as a dependency with maven, look at my pom.xml) - a test class where methods to test are annoted with @Test - a testng.xml to run the test. With eclipse plugin, no problem to run test (right click on the project -> Run As -> TestNG Suite) after installing the plugin (and updating maven sources). But with maven (in a shell), I've got this : #mvn clean test [INFO] Scanning for projects... [INFO] ---------------------------------------------------------------------------- [INFO] Building Unnamed - TestNew:TestNew:jar:0.0-SNAPSHOT [INFO] task-segment: [clean, test] [INFO] ---------------------------------------------------------------------------- [INFO] [clean:clean] [INFO] Deleting directory /home/bchaffangeon/workspace/New/target [INFO] Deleting directory /home/bchaffangeon/workspace/New/target/classes [INFO] Deleting directory /home/bchaffangeon/workspace/New/target/test-classes [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] Compiling 1 source file to /home/bchaffangeon/workspace/New/target/test-classes [INFO] [surefire:test] [INFO] Surefire report directory: /home/bchaffangeon/workspace/New/target/surefire-reports org.apache.maven.surefire.booter.SurefireExecutionException: org.testng.internal.annotations.JDK15AnnotationFinder; nested exception is java.lang.InstantiationException: org.testng.internal.annotations.JDK15AnnotationFinder; nested exception is org.apache.maven.surefire.testset.TestSetFailedException: org.testng.internal.annotations.JDK15AnnotationFinder; nested exception is java.lang.InstantiationException: org.testng.internal.annotations.JDK15AnnotationFinder org.apache.maven.surefire.testset.TestSetFailedException: org.testng.internal.annotations.JDK15AnnotationFinder; nested exception is java.lang.InstantiationException: org.testng.internal.annotations.JDK15AnnotationFinder java.lang.InstantiationException: org.testng.internal.annotations.JDK15AnnotationFinder at java.lang.Class.newInstance0(Class.java:335) at java.lang.Class.newInstance(Class.java:303) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.<init>(TestNGDirectoryTestSuite.java:86) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.apache.maven.surefire.Surefire.instantiateObject(Surefire.java:216) at org.apache.maven.surefire.Surefire.instantiateSuite(Surefire.java:243) at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:145) at org.apache.maven.surefire.Surefire.run(Surefire.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Sat Feb 10 18:40:13 CET 2007 [INFO] Final Memory: 4M/8M [INFO] ------------------------------------------------------------------------ zsh: exit 1 mvn clean test The testng doc says (http://testng.org/doc/maven.html) that the last testng plugin for maven could be required if we experienced some issues. So I put this in pom.xml : <pluginRepositories> <pluginRepository> <id>tapestry.javaforge</id> <url>http://howardlewisship.com/repository</url> </pluginRepository> </pluginRepositories> But maven says : Unable to get resource from repository tapestry.javaforge (http://howardlewisship.com/repository) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. GroupId: org.apache.maven.plugins ArtifactId: maven-plugins Version: 2-SNAPSHOT Reason: Unable to download the artifact from any repository org.apache.maven.plugins:maven-plugins:pom:2-SNAPSHOT from the specified remote repositories: central (http://repo1.maven.org/maven2), tapestry.javaforge (http://howardlewisship.com/repository) However a bug in codehaus Jira has been opened : http://jira.codehaus.org/browse/SUREFIRE-58?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel Here are my files : pom.xml --------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>TestNew</groupId> <artifactId>TestNew</artifactId> <version>0.0-SNAPSHOT</version> <description>TestNew</description> <build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <defaultGoal>test</defaultGoal> <testResources> <testResource> <directory>test/ressources</directory> <includes> <include>*.*≤/include> </includes> <excludes> <exclude>*.launch</exclude> </excludes> </testResource> </testResources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <groups>functest,util</groups> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>5.5-jdk15</version> </dependency> </dependencies> <!-- <pluginRepositories> <pluginRepository> <id>tapestry.javaforge</id> <url>http://howardlewisship.com/repository</url> </pluginRepository> </pluginRepositories> --> </project> --------------------------------------------------- testng.xml --------------------------------------------------- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="TestNew" verbose="1" > <test name="TestNew" > <classes> <class name="org.nuxeo.testing.TestNew" /> </classes> </test> </suite> --------------------------------------------------- TestNew.java --------------------------------------------------- package org.nuxeo.testing; import org.testng.annotations.Test; public class TestNew { @Test public void Test1() { assert "HelloWorld".equals("HelloWorld"); } @Test public void Test2() { assert "HelloWorld".equals("HelloWorld"); } @Test public void Test3() { assert "HelloWorld".equals("HelloWorld"); } } --------------------------------------------------- Does someone got an idea? NB : I'm definitvely not a Maven2 expert (actually it's my first time!) so my pom.xml may miss some important order.
RSS Feed