11 Replies Latest reply on Jan 20, 2012 7:59 PM by daniel_spasojevic

    Alpha5 and TestNG DataProvider

    Benjamin Schröder Newbie

      Hey there,

       

      i have some question regarding the TestNG DataProvider and Arquillian. I have a test like the one below that works fine with Alpha4 using TestNG Version 5.14.6 and arquillian-weld-se-embedded-1 Version 1.0.0.Alpha4.

       

       

      @Inject

      private BeanUnderTest beanUnderTest;

       

      @Deployment

      public static JavaArchive createDeployment() {

          return ShrinkWrap

              .create(JavaArchive.class, "test.jar")

              .addClasses(BeanUnderTest.class, BeanUnderTestDependencyMock.class)

              //Alpha4 .addManifestResource(new ByteArrayAsset("<beans/>".getBytes()),

              .addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()),

                  ArchivePaths.create("beans.xml"));

      }

       

      @Test(dataProviderClass = MyObjectCreator.class, dataProvider = "data")

      public void transformTest(final MyObject myObject) {

          MyTranformedObject mto = beanUnderTest.transform(myObject);

          /* ... assertions ... */

      }

       

      Method from data prvider class:

       

      @DataProvider(name = "data")

      public static Object[][] data() {

          MyObject myObject1;

          MyObject myObject2;

          /* ... */
             
          return new Object[][] { { myObject1}, {myObject2} };

      }

       

      If I try to run this test setup with Alpha5 the following Exception is thrown:

       

       

      org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve managed beans for Types: [class

      de.test.package.MyObject]; Bindings: [@javax.enterprise.inject.Default()]

          at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:807)

          at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:793)

          at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.getInstanceByType(CDIInjectionEnricher.java:81)

          at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.resolve(CDIInjectionEnricher.java:71)

          at org.jboss.arquillian.impl.execution.LocalTestExecuter.enrichArguments(LocalTestExecuter.java:98)

          at org.jboss.arquillian.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:63)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)

          at org.jboss.arquillian.impl.core.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:61)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)

          at org.jboss.arquillian.impl.client.ContainerDeploymentContextHandler.createContext(ContainerDeploymentContextHandler.j

      ava:133)

          at org.jboss.arquillian.impl.client.ContainerDeploymentContextHandler.createTestContext(ContainerDeploymentContextHandl

      er.java:120)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.TestContextHandler.createTestContext(TestContextHandler.java:82)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)

          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.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)

          at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:101)

          at org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:102)

          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.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:189)

          at org.testng.internal.Invoker.invokeMethod(Invoker.java:666)

          at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)

          at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)

          at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)

          at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)

          at org.testng.TestRunner.runWorkers(TestRunner.java:1125)

          at org.testng.TestRunner.privateRun(TestRunner.java:749)

          at org.testng.TestRunner.run(TestRunner.java:600)

          at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)

          at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)

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

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

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:920)

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

          at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)

          at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)

          at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)

       

      So isn't it possible to run many test cases with a TestNG DataProvider in Alpha5 or am I doing something wrong?