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

Source: Internet
Author: User
Tags generator generator server hosting 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 a variety of tests on the database, one of the most useful features is the ability for developers in the testing phase, a lot of convenient to generate random data for the database, but also can specify the rules for generating data, it is very convenient, so that in the test process , developers can have more data samples to test the project. This article describes the use of data generation in this method.

1 Creating a SQL Server 2008 database project

First, open Visual Studio 2010, select New Project, and in the, select Build a SQL Server 2008 database project named Sampledbapp

2 Importing Data

After the database project is established, we can then import the data objects, which will import the data objects in the existing database into our established database project. First we want to connect to the database, right-click in the database project, select "Import Data Objects and Settings" in the popup menu, such as:

This will open a Data Import wizard window, for example, will prompt the user to connect to the existing database, we just need to follow the wizard to complete the steps.

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

server hosting King Ann faster! "click into" the computer room located in the backbone node, the user access to the country's fastest website. Jingan-Henan's larger multi-line server colocation provider! View

3 Adding a data generation plan

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

Continue to select Add Data conversion plan in the pop-up window, such as:

4 Select the table to add

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

In, for example, like the Products table, you can also set its associated table, such as the Categories table, and set its associated relationship (set in the ratio to related column), such as 1:1 one-to-one relationships. While in the lower column section, note that each column in the generator generator can even be set using regular expressions to generate data, such as very handy.

5 Generating data

Once the above steps are complete, you can randomly generate the test data in the data table at the click of the Generate button or F5, and at the time of the build, you will be asked whether to generate test data in the existing database tables or to choose a different destination for the build.

6 Verifying the generated data

Finally, after the data is generated, you can check the generated data into SQL Server, for example, Visual Studio's data generator does generate a lot of test data for us.

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

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

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.