Visual Studio unit test 3 --- stress test

Source: Internet
Author: User

Original article: Visual Studio unit test 3-stress test

 

We all know the well-known loadruner, but few people know that Visual Studio's test can also perform simple stress tests. Next we will introduce how to use Visual Studio for stress testing.

This article is the previous blog post: One of Visual Studio unit tests-the subsequent chapter of common unit tests. If you are not familiar with the unit test of Visual Studio, refer to the previous article. Http://blog.csdn.net/tjvictor/archive/2011/02/09/6175362.aspx

This article will automatically skip the concepts and methods mentioned in the previous article. The example in this article can be downloaded using the following link:

Http://download.csdn.net/source/3014236

During stress testing, Visual Studio records a large amount of data and stores the data in the database. Therefore, before conducting stress testing, let's prepare the database.

· Run the C:/program files/Microsoft Visual Studio 10.0/common7/IDE/loadtestresultsrepository. SQL script in sqlserver to create a test database (this script is also available in the corresponding vs2008 directory)

· Configure the stress test database: Test-> Manage test controllers. Configure the database you just created. For example:

 

Create a new function in the mathutility. CS file:

Public static void powertest ()

{

Random R1 = new random (datetime. Now. gethashcode ());

Random r2 = new random (datetime. Now. adddays (1). gethashcode ());

Double D = r1.next () * r2.next ();

Random R3 = new random (convert. toint32 (d ));

String STR = r3.next (). tostring ();

Stringbuilder buffer = new stringbuilder ();

Foreach (char a in Str. tochararray ())

Buffer. append (string. Format ("{0}-{1}", A, A + ));

}

Create a unit test function for this function.

 

Create a stress test:

1. Add-> new test:

2. Welcome Page

3. Set the name of the test scenario, think time, and iteration time.

4. Set the pressure user model.

5. Set a hybrid model for stress testing. You can select an appropriate model based on your testing scenario.

6. Set stress test functions. These functions are all unit test functions. You can add multiple stress functions and the number of people following them is the number of persons under pressure required by this stress function.

7. Set the network. This option works when stress testing is closely related to the quality of the network.

8. performance counters. You can add related counters in perfmon. This article does not discuss how to add custom counters. I will post another blog post for discussion.

9. Set the pressure time and other options.

 

10. The loadtest file after the setting is complete.

 

Click "run" to start the stress test. If you follow the steps above, you will see a stress test diagram similar to the following (due to different machine performance, local data will be different ):

1. images that run for 3 minutes

2. Graphics when the operation is complete

Stress Test report after running

 

So far, we have completed a complete stress test. Stress Testing is complex and has many options. If you are interested, try it one by one. I will not describe the meanings and scenarios of all options here.

 

Finally, we will introduce Load Test manage. For example:

It can be seen that I have performed multiple stress tests, and each time the data is saved in the set database, we can use this form to view and call the previous stress test results and data.

 

Now, the basic usage of stress testing has been completed. The following describes the generic testing, database testing, and UI testing.

 

If you need to reprint, please indicate the original from the wolf's blog: http://blog.csdn.net/tjvictor

 

Visual Studio unit test 3 --- stress test

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.