4 Replies Latest reply on Jun 24, 2015 8:46 AM by Stéphane Masper

    Arquillian persistence - test not failing when dataset is not correct

    Gaelle Guimezanes Newbie

      I created a integration test with some @RunAsClient tests, and a prior server-side test that was only there to inject data before the client tests (cf [ARQ-1077] Persistence Plugin does not work with Drone/Graphene - JBoss Issue Tracker).

      My dataset was not correctly populated (I had forgotten to add values for some columns that I didn't need for the tests, but that had the @NotBlank annotation, silly me).

      I spent quite some time understanding why the first client test could not find the data I had inserted, while the test populating the data was successful... Then I discovered that even adding an Assert.fail() in the body of the test that inserted the data did not make the test fail!

       

      @Test
      @UsingDataSet({ "datasets/my_current_dataset.yml" })
      @InSequence(1)
      public void prepare_data_for_tests() {
          // this test is a workaround as there is no "elegant" way to set up the
          // database just once for all tests in the class.
          
          Assert.fail("Should fail if test is actually executed");
      }
      
      @RunAsClient
      @Test
      @InSequence(2)
      public void should_create_my_object_when_parameters_are_correct(
              @ArquillianResource URL baseURL) {
      
          // do real testing...
      }
      

       

      I have two issues with this:

      1. The test annotated with @UsingDataSet should fail if the dataset is not correct... or if it does not fail then the inside of the test should be executed (I have tried adding some logging etc. inside the test but nothing gets executed). NB : when the insert fails, it does not rollback, e.g. the data that was correct is actually in the database, only the incomplete data was not inserted.
      2. There should be some trace somewhere about what went wrong, so that I don't spend my whole day finding out what's wrong with my dataset. After some googling I have tried adding log4j.logger.org.dbunit=TRACE in my logging.properties (that I added in my ShrinkWrap archive in the test) but that gave me nothing. My datasource has hibernate.show_sql set to true, but the sql from the dataset injection is nowhere to be found.

      Does anyone know how to make the data injection verbose enough so that at least the not-inserted data can be easily spotted?

        • 1. Re: Arquillian persistence - test not failing when dataset is not correct
          Robert Panzer Newbie

          Hi,

           

          could it it be that you are using arquillian-core 1.1.4.Final?

          If so could you please retry with 1.1.5.Final?

           

          kind regards

          Robert

          • 2. Re: Arquillian persistence - test not failing when dataset is not correct
            Nico Schlebusch Newbie

            Hi,

             

            I had the same problem a few weeks back and it took me a few days to find the problem as well. I agree that the test should fail with an appropriate message when seeding the db fails. I was having the issue with Arquillian 1.1.4.Final, but can't remember if 1.1.5.Final had the same problem.

             

            Kind regards

            Nico

            • 3. Re: Arquillian persistence - test not failing when dataset is not correct
              Rafael Pestano Novice

              Hi there,

               

              my problem with wrong datasets is similar, im using core 1.1.5 and persistence Alpha7 and when my dataset is wrong i receive a NullPointerException with no relevant information of what's wrong with the dataset(eg. missing non nullable column, or wrong column name), is it a known issue or a problem with my setup?

               

              here is the stacktrace:

               

              java.lang.NullPointerException

                  at org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler.testRequiresRollbackDueToFailure(TransactionHandler.java:170)

                  at org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler.rollbackRequired(TransactionHandler.java:159)

                  at org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler.endTransaction(TransactionHandler.java:123)

                  at org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler.endTransactionAfterTest(TransactionHandler.java:102)

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

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

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

                  at org.jboss.arquillian.testenricher.cdi.CreationalContextDestroyer.destory(CreationalContextDestroyer.java:44)

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

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

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

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

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

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

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

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

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

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

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

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

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

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

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

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

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

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

                  at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:277)

                  at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)

                  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

                  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

                  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

                  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

                  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

                  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:193)

                  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:345)

                  at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:49)

              • 4. Re: Arquillian persistence - test not failing when dataset is not correct
                Stéphane Masper Newbie

                Hi everybody,

                it's almost one year after but I've spend many hours to try to figure out how to fix this and for me the issue was indeed (#####!!!@!F######) that there was some <TAB> character in my dbunit dataset (YAML).

                Hope it will help someone one day...