How to use Visual Studio 2010 to generate random test data in a database _mssql

Source: Internet
Author: User
Tags generator generator generator visual studio 2010

Testing is an important part of the project, and in Visual Studio 2010, it has been well supported in testing, such as unit testing, load testing, and so on. In the area of data testing, Visual Studio 2010 also supports multiple tests of a database, one of the very handy features that makes it easy for developers to generate random data for a database in the testing phase, and to specify the rules for generating data themselves, which allows , developers can have more than enough data samples to test the project. This article describes the use of the data generation generator.

1 Creating a SQL Server 2008 database project

First, open Visual Studio 2010, select a new project, and in the following illustration, select a database project to build a SQL Server 2008 named Sampledbapp

2 Importing Data

After we have established the database project, we can then import the data objects into the database project that we have built. First we want to connect to the database, the right mouse button in the database project, select "Import Data Objects and Settings" in the pop-up menu, as shown in the following figure:

This will open a Data Import wizard window, the following figure, will prompt the user to connect the existing database, we simply need to follow the wizard said Step-by-step to complete.

After the data import is complete, the following message appears, indicating that the data has been imported successfully.

3 Adding data Generation plans

At this point, we can start adding a data generation plan. In the pop-up menu after the right mouse button in the project, select "Data Generation plan", as follows:

In the pop-up window, continue to choose to increase the data conversion plan, as shown in the following figure:

4 Select the table to add

Next, the tables that are already in the database are displayed for the user to choose which tables to generate data from, and when the user selects a table, all columns in the table appear below the screen to allow the user to select which columns to generate the data.

In the previous illustration, such as the Products table, you can also set its associated table, such as the Categories table, and set its association relationship (set in the ratio to related column), such as 1:1 one-to-one relationships. In the lower part of the column, note that in each of the columns in the generator generator, you can even set the use of regular expressions to generate data, the following figure is very convenient.

5 Generating data

After the above steps are completed, you can point to the following picture of the Build button or F5, you will be immediately in the data table randomly generated test data, at the time of generation, the system asks whether to generate test data in an existing database table, or choose a different generated destination.

6 Verify the generated data

Finally, after data generation, you can check the generated data into SQL Server, as shown in the following illustration, which shows that the data generator for Visual Studio does generate a lot of test data for us.

Microsoft Official Document: http://msdn.microsoft.com/en-us/library/dd193262 (v=vs.100). aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.