We all know the famous loadruner, but few people know that Visual Studio's own test can do some simple stress tests, so let's show you how to use Visual Studio for stress testing.
This article is one of the previous posts: Visual Studio Unit Tests---A follow-up chapter of common unit Tests. If the reader is unfamiliar with the unit test for Visual Studio, please take a look at it first. Http://blog.csdn.net/tjvictor/archive/2011/02/09/6175362.aspx
This article will automatically omit the relevant concepts and methods mentioned in the previous article. Examples of this article can be downloaded using the following link:
http://download.csdn.net/source/3014236
When you do stress testing, Visual Studio records a large amount of data and saves the data in the database, so let's do a good job of preparing the database in between stress tests.
· Execute C:/Program files/microsoft Visual Studio 10.0/common7/ide/loadtestresultsrepository.sql script inside SQL Server to create a test database ( VS2008 the corresponding directory below also has this script)
· Configure the Stress test database: Test->manage test controllers, configuring a newly built database. The following figure:
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 + a));
}
and create the unit test function for this function.
New Stress test:
1.add->new Test:
2. Welcome interface
3. Set the name and thinking time of this test scenario (think times) and iterative thinking time
4. Set the pressure user model.
5. Set up a mixed model of the stress test. You can choose the right model according to your test scenario.
6. Set the pressure test function, these functions are unit test functions, can add multiple pressure functions and the number of people behind this pressure function requires pressure.
7. Set up the network. This works when stress tests are closely related to the quality of the network.
8. Performance counter. You can increase the related counters in Perfmon. about how to add custom counters is not what is discussed in this article. I'll post another blog post for discussion.
9. Set pressure time and other options.
10. Set the completed LoadTest file.
Click on the above image of the operation can start this stress test. If you set the above steps, you will see a stress test diagram similar to the following (local data will vary depending on machine performance):
1. Graphics running for 3 minutes
2. Graphics when the run is complete
The stress test report after the operation is completed
At this point, we have completed a complete stress test. The situation of the stress test is more complicated, the options are more, if you are interested, please try one at a while. I'm not going to describe all the options and the scenario one by one I use here.
Finally, the load Test Manage is described in the following figure:
Visible, I did a number of stress tests, each time the data are saved in the database just set up, we can use this form to view, call the previous stress test results and data.
Now that the basic usage of the stress test has been finished, the following is an introduction to generic testing, database testing, UI interface testing.
If you want to reprint, please specify this article original from the Wolf blog: http://blog.csdn.net/tjvictor