Discussion MS Test Data Generation Feature Not Usable Scenario

  • Tuesday, July 17, 2012 9:18 AM
     
     

    Hello experts,

    We are using data generation plan feature provided by MSTest for unit testing the database business logic.

    During our tests, we encountered a scenario where data generation feature is not suitable for our needs.

    Below is the description of the situation.

    The data generation plan is prepared based on the database schema available at that moment.

    But whenever application database is created during our daily builds, new date time constraints are added to some of the columns based on the setup time of the database.

    The constraint defines a single date range for the date time column.

    Executing the already prepared data generation plan fails to pump data into tables due to violation of constraints (since randomly generated date time values will not satisfy the constraint defined on the column)

    Hence data generation plan and unit test execution is failing.

    Can somebody assist me if they have encountered such a scenario in their projects?

    Thanks & Regards

    Samba

All Replies

  • Wednesday, July 18, 2012 5:05 AM
    Moderator
     
     

    Hi Samba,

    I am moving your thread into the Visual Studio Database Development Tools (Formerly "Database Edition Forum") Forum for dedicated support. Thanks for your understanding.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, July 19, 2012 6:44 AM
    Moderator
     
     

    Hi Samba,

    What is the Generator you use for that datetime column? I suspect you are using the DateTime Generator. If you create constraints for that datetime column and do not want to generate radom data, instead of using DateTime Generator you should use Sequential data bound generator.

    And for your scenario, if you would like to insert setup time of database as values to that datetime column, you can first save the data in a excel file for example. After that, you can use the Sequential data bound generator to read data in the excel and then insert it to that datetime column. For more detailed steps, see my reply in this case: http://social.msdn.microsoft.com/Forums/en/vstsdb/thread/f7bac4e2-51d0-46a6-8e24-e46e13757186

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, July 19, 2012 8:24 AM
     
     

    Hello Vicky,

    Thanq for your response.I will go through it definitely.

    Let me provide few more details regarding our scenario.

    We create a database on daily basis for automated build purpose.Depending on some configuration data, certain number of similar tables will be created. A datetime check constraint is added to timestamp column present in all these tables.below is the illustration.

    Table1 -constraint July 1 to July 10

    Table2 -constraint July 11 to July 20

    Table3 -constraint July 21 to July 30

    The database creation time is taken as reference for defining the datetime check constraint on the first table.The constraints on other tables will be relative to table1.

    In general i can say that the number of tables and constraints on the tables are going to change continuously.So reading from excel , iam not sure how far it will solve the issue.

    we need data generation plan to address this situation.

    Thanks & Regards

    Samba



  • Friday, July 20, 2012 9:00 AM
    Moderator
     
     

    Hello Samba,

    If I understand your scenario correctly, actually you do not have already created your tables and databases, and you would like to create the tables automatically? If so, why do you want to achieve that by using data generation plan? As far as I know that data generation plan is used to insert data to existing tables, it is not used to create tables. If I misunderstand you, please kindly correct me.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, July 23, 2012 5:42 AM
     
     

    Hello Vicky,

    Your understanding regarding the scenario is invalid and let me explain once again.

    We have database scripts already available for production.We have daily builds for continuous integration test.

    When the build is triggered, the database scripts will be executed and DB will be created.Based on the script execution time, date time check constraints are added to few columns . Below is the example

    Table1 -constraint July 1 to July 10

    Table2 -constraint July 11 to July 20

    Table3 -constraint July 21 to July 30

    As a result of these dynamic constraints(changes daily with new DB), The data generation plans are failing to insert data into these tables as random datetime values causes these check datetime constraints to fail.Also setting min/max values for the timestamp columns in the data generation plan doesn't solve these run time constraints issue.

    Thanks & Regards

    Samba

  • Friday, July 27, 2012 10:03 AM
    Moderator
     
     

    Hi Samba,

    Sorry for the late response. And do you still have that issue?

    And for your scenario, I am afraid that there is no one easy way to do so. Maybe you can first get the script execution time programmatically and create 3 files to store some pre-definied values which meet the check constraints programmatically. And then to configure the Sequential data bound generator to read data in these files.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us