Arquillian persistence - test not failing when dataset is not correct
gguimezanes Jul 28, 2014 11:45 AMI 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:
- 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.
- 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?