I'm wondering if there is a way to specify the date in the DBUNIT XML dataset tomorrow. Sometimes code logic is different for future dates and dates and I want to test both cases. Of course, I can specify something on November 5, 2239, and can ensure that this test will work till this date, but there is no more great way out there.
I have not encountered such a situation in my Java development so far, but once I had the experience when two days before the dates of the dates, code logic was different two days before the dates . In this case, the only possible solution for writing database based tests is to include relative dates during the data import.
Is there any facility provided by DBUNET for this?
I'm just starting to use DBUnet and I'm looking for similar capabilities. Unfortunately, there is no language of expression for the dates in the structure. However, I found an appropriate solution using the DBUNIT Replacement Dataset Class. This class takes an IDataSet object and displays the ways to change the object extracted by the Data Set files from the IDataSet object.
Dataset
& lt; Dataset & gt; & Lt; User first_name = "donation" last_name = "smith" create_date = "[create_date]" /> & Lt; Dataset & gt;
source code
string dataset file = "testDataFile.xml"; IDataSet Dataset = New FlatXmlDataSetBuilder (). Build (new FileInputStream (dataSetFile)); Replacement data reset rDataSet = new replacement data set (dataset); Set up & lt; String & gt; Keys = Dataset Adjustments.keySet (); RDataSet.addReplacementObject ("[create_date]", datediethiethudesday (new date (), -2));
Now, when the test runs user's creation data, the test will be set up two days before running.
Hope it helps best wishes.
Comments
Post a Comment