13 Replies Latest reply: Apr 25, 2012 8:32 AM by Laurent Tisseyre RSS

    @RunWith(Arquillian.class) fail

    Laurent Tisseyre Newbie

      Hi,

       

      I'm trying to run tests with arquillian but without success.

      I have an exception when tests run :

       

      Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

      I've seen these topics on the forum but my problem has not been resolved.

       

      I need your help,

       

      Here is my pom.xml :

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <project xmlns="http://maven.apache.org/POM/4.0.0"

               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

                                   http://maven.apache.org/xsd/maven-4.0.0.xsd">

          <modelVersion>4.0.0</modelVersion>

       

          <parent>

              <groupId>org.monGroupId</groupId>

              <artifactId>threejs</artifactId>

              <version>2.x-SNAPSHOT</version>

          </parent>

       

          <!-- =========================================================== -->

          <!--     Module Description                                                                                       -->

          <!-- =========================================================== -->

          <groupId>org.monGroupId</groupId>

          <artifactId>test-threecomponent</artifactId>

          <packaging>war</packaging>

          <name>arquilliam tests</name>

          <description>Test threecomponent component using arquilliam.</description>

       

          <properties>

              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

          </properties>

       

          <dependencyManagement>

              <dependencies>

                  <dependency>

                      <groupId>org.jboss.arquillian</groupId>

                      <artifactId>arquillian-bom</artifactId>

                      <version>1.0.0.Final</version>

                      <scope>import</scope>

                      <type>pom</type>

                  </dependency>

              </dependencies>

          </dependencyManagement>

       

       

          <build>

              <plugins>

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>2.3.2</version>

                      <configuration>

                          <source>1.6</source>

                          <target>1.6</target>

                      </configuration>

                  </plugin>

              </plugins>

          </build>

       

          <dependencies>

              <dependency>

                  <groupId>org.jboss.spec</groupId>

                  <artifactId>jboss-javaee-6.0</artifactId>

                  <version>1.0.0.Final</version>

                  <type>pom</type>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <version>4.8.1</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.arquillian.junit</groupId>

                  <artifactId>arquillian-junit-container</artifactId>

                  <scope>test</scope>

              </dependency>

          </dependencies>

       

      </project>

       

       

       

       

      Here the exception :

       

      -------------------------------------------------------------------------------

      Test set: org.mapfaces.test.PersonTest

      -------------------------------------------------------------------------------

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.379 sec <<< FAILURE!

      org.monGroupId.test.PersonTest  Time elapsed: 0.379 sec  <<< ERROR!

      java.lang.RuntimeException: Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor see cause.

                at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170)

                at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)

                at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)

                at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)

                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)

                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.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

                at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

                at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

                at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)

                at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

      Caused by: java.lang.reflect.InvocationTargetException

                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.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)

                ... 14 more

       

       

       

       

       

      A simple class to test :

       

      public class Person {

          private String name;

       

          public Person(String name) {

              this.name = name;

          }

       

          public String getName() {

              return name;

          }

       

          public void setName(String name) {

              this.name = name;

          }

      }

       

       

       

       

      And the tests:

       

      import javax.inject.Inject;

      import junit.framework.Assert;

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.JavaArchive;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      /**

      * Class test

      * Not implemented yet

      */

      @RunWith(Arquillian.class)

      public class PersonTest {

       

          @Deployment

          public static JavaArchive createDeployment() {

              return ShrinkWrap.create(JavaArchive.class)

                  .addClass(Person.class)

                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

          }

       

          @Inject

          Person greeter;

       

          @Test

          public void getName() {

              System.out.println("getName");

              String result = "test";

              greeter = new Person(result);

              Assert.assertEquals(result, greeter.getName());

          }

      }

       

      Thank you in advance!