简体   繁体   中英

Adding a Form to Visual Studio 2015 Load Test

I am writing a Load test for a web service in Visual Studio 2015 Enterprise.

One of the required web request headers is a token that provides web service authentication information.

I get this token from a Login form that I am trying to pull up before my test executes.

Something like this:

    public override IEnumerator<WebTestRequest> GetRequestEnumerator ()
        {
            MyForm f = new MyForm();
            string auth = f.Login(); //also shows form

            //Then all the web request stuff, including:
            ResourceWebTest.Headers.Add(new WebTestRequestHeader("Authorization", "Token " + TokenAuthenticate));

            yield return ResourceWebTest;
        }

But when I run this, I don't see a form. I simply get 'Unauthorized', probably because 'auth' is going through as an empty string.

Why isn't my form showing up? Can I get it to appear?

(Edit: I should note that hardcoding the authentication token directly works.)

The answer to my issue was to learn how to properly record a Web Test. Logging in while recording replaced the need to manually show a login form while running the test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM