Hi All,
Before directly describing the problem, I want clarification on working of DBUnit 2.4.6, I am asking these questions because I am getting problem in this area only :
1). Is it necessary to have data in database before executing the DBUnit
test case?
2). If there is no data in database and if I am executing the DBUnit test case, then what will happen ?
When I say
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);, that means it will delete all the data and will insert fresh data from the dataset (from the xml file). According to my understanding in this case, whether data exists in database or not, if there is dataset exists (the xml file containing data ) then there won't be any problem. But in my case this is not happening, it is not inserting or updating or deleting (delete using DELETE_ALL when data exists) the data while database is empty.
Below is the dataset and same data does exists in MySQL database also:
There are two tables:
product_brand and
product_model. "brandId" is primary key in "product_brand" table and foreign key in "product_model" table as field "theBrand_brandId"
Now I am adding one line as below:
In
product_model table for
modelId="3", I am assigning
theBrand_brandId="2".
These above are the changes which I have made to execute my test case but while executing it, nothing is reflecting in database table as I am expecting the result. No new row is getting added and no column is updated. Test case pertaining to JUnits are working fine like:
While debugging, it is executing each scenario but not according to the updated dataset file. I also checked with cache, cleaned up the workspace using
maven as well. So just want tips, advice or favor of solution. I am sticking code bellow:
Test Case:
Kindly let me know if the information provided to the problem is sufficient or required more info.
Best Regards,
Pratik