Insert 120 second wait in Visual studio Webtest

2019-03-06 12:17发布

问题:

I want to add a delay of 120 second between the execution of two web requests. I have tried using think time but it won't pause the execution for 120 sec.

Can anyone please let me know how to add wait to pause the execution for 120 second (after say 2 web request execution) and then proceed the execution for next request.

I am using visual studio 2015.

回答1:

Think times are processed after the response is received. So to have a delay between two requests set the think time on the first request. I have successfully used long sleep times. Think times can be disabled in a test so make sure they are enabled:

1 In the ".testsettings" file, in the Web test section.

2 In the Think profile property of the scenario. If the delay should be (as near as possible to) exactly 120 seconds then set the profile to On.

3 The default for when Visual Studio runs a standalone web test is to not use think times. Thus everything runs as fast as possible. The setting in (1) above can be used to change the default. A temporary change to the default can be made from the "Edit test settings" command of the web test results window; this change only applies to test runs started by the "Click here to run again" in the same window.

If the two requests are actually different web tests then the Think time between test iterations property of the scenario may be useful.

Do not use any of the task or thread delay (or sleep) methods if there is any chance that this test will be used as part of a load test as they will stop many virtual users from running. See the first part of this answer for a fuller explanation. A delay or sleep call might be used if the web test will never be used within a load test.



回答2:

You can do this

 Thread.Sleep(Number_Second);