7 Replies Latest reply on Sep 22, 2012 12:56 PM by Bartosz Majsak

    Strange Behavior with @ShouldMatchDataSet in APE

    Bryan Saunders Newbie

      I am developing some tests using APE and have come across some strange behavior with the @ShouldMatchDataSet annotation. The problem I am having is when I run my tests, and I pass it the Dataset that I expect to see after the test it passes, but it will also pass if I give it an Empty Dataset. If I give it an incorect Dataset it will properly fail.

       

      For instance, if I seed the test with this Dataset:

       

      *Seed Dataset*

      {code}

      <dataset>

           <user id="1" firstName="Bryan" lastName="Saunders"/>

            <user id="2" firstName="Joe" lastName="Bob"/>

      </dataset>

      {code}

      and in my test I delete User #2, I expect to see this Dataset

       

      *Correct Result Dataset*

      {code}

      <dataset>

           <user id="1" firstName="Bryan" lastName="Saunders"/>

      </dataset>

      {code}

      If I pass it that Dataset, the test will pass, and if I pass it either of the following dataset's it will fail.

       

      *Bad Result Dataset 1*

      {code}

      <dataset>

           <user id="1" firstName="Bryan" lastName="Bob"/>

      </dataset>

      {code}

       

      *Bad Result Dataset 2*

      {code}

      <dataset>

           <user id="1" firstName="Bryan" lastName="Saunders"/>

           <user id="2" firstName="Joe" lastName="Bob"/>

      </dataset>

      {code}

      However, if I pass it this dataset,

       

      *Empty Dataset*

      {code}

      <dataset/>

      {code}

      The test will happily pass. Even though only one row was deleted, and there is still data in the database. From what I can tell from my testing and from analyzing the data dumps from the tests, it is using the following process to check the tabls

       

      {code}

           if( FileRowCount == TableRowCount ){

                if( FileRowData == TableRowData ){

                     Pass Test

                }else{

                     Fail Test

                }

           }else if( FileRowCount < TableRowCount ){

                Pass Test

           }else{

                Fail Test

           }

      {code}

      I have checked the source code for DbUnit 2.4.8 and it appears to not work this way, and should be failing whenever the number of rows in the file and the database do not match, so I have no idea what is going on here. Has anyone else had this problem, or seen this behavior?

       

      I am running Arqullian 1.0.1.Final and Alpha5 of APE and have tried it in both AS 7.1 and EAP6 on RHEL 6.2 using an H2 in-memory Database.