Arquillian - testing Weld application
marx3 Feb 3, 2011 5:43 AMHello
I'm trying to make applications withs tests. There is hovewer big mess with tests.
My application will use Weld, Hibernate and JBoss AS6, is written in Eclipse, so it's rather usual configuration and first choice for CDI environment.
1) testng or junit? Which one to use?
2) Embedded or remote container? and what's managed container?
Support matrix
http://community.jboss.org/wiki/ArquillianContainerInjectionSupportMatrix
doesn't help in choosing at all.
Which one should I use? Remote AS 6? Embedded Weld?
4) Maven hell...
- I have to choose between testng and junit - both will not work together (ok, I can understand that, but it should be written somewhere)
- Weld archetype has errors and in no way helps with Arquillian (ok, Arquillian is Alpha...)
- everyone on the net use different method to launch tests with Arquillian, they use profiles or not, thay choose different containers, and what is worst - everyone use different version of Jboss, Arquillian, junit/testng etc. I can't simply tell Maven - use the newest compatible. No - I have to write version exect number. Some uses snapshots - but suddenly they are absent. Some version even doesn't exists but are advised in Arquillian documentation...
5) I see in Weld archive that some examples uses selenium framework - but there is no description how to use them anywhere. I know Selenium, i know that richfaces team use it for internal testing, and it would be nice to be able to use it together with Arquillian. It should be described anywhere.
6) Eclipse has plugins for Maven and testng/junit. There is no clear description how to use them together with Arquillian (and profiles). Usually there is need:
- to deploy locally (local jboss) - it works ok from command line and from Maven plugin (using run configuration)
- to test locally (local jboss, maybe embedded container for tests?) - tests are also run automatically with deploying, but if I have different profile for testing - they doesn't pass...). I can do "mvn test" and "mvn test -P"profile" - but how to use it with testng/junit plugin?
7) Usually Hudson/Continuum or sth like this tests nightly builds and produce snaphots/releases - I hope that it will be possible to confugure it with junit/testng, Arquillian and maybe Selenium...?
8) I've attached very simple project created from Weld archetype. I was trying to configure Arquillian test but they doesn't work:
- "mvn package":
{code}
-------------------------------------------------------------------------------
Test set: dummy.HelloTestCase
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE!
initializationError(dummy.HelloTestCase) Time elapsed: 0.002 sec <<< ERROR!
java.lang.NullPointerException
at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)
at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:77)
at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:85)
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:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)
at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
{/code}
- "mvn test -Pweld-ee-embedded-1.1", "mvn test -Pjbossas-remote-60":
{code}
-------------------------------------------------------------------------------
Test set: dummy.HelloTestCase
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.009 sec <<< FAILURE!
initializationError(dummy.HelloTestCase) Time elapsed: 0.002 sec <<< ERROR!
java.lang.NoClassDefFoundError: org/jboss/arquillian/spi/ExtensionConfiguration
at org.jboss.arquillian.impl.XmlConfigurationBuilder.build(XmlConfigurationBuilder.java:112)
at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:84)
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:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)
at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.ClassNotFoundException: org.jboss.arquillian.spi.ExtensionConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 23 more
{/code}
Can anybody help me create working, testable project?
-
zmaz.zip 143.2 KB