Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Okay so I have created a very simple webtest. The purpose of this webtest is to attempt to login whilst simulating a few failing attempts.

The webtest has the obvious credentials associated with it:-

Username Password What I want to be able to do is when I associate the web test with a load test I want to be able to login with 25 users using multiple different credentials, how can I set these and then tell the test to use the multiple credentials?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

you could use a plugin, although there is a simpler way. You can create a CSV file with the list of usernames and passwords you want to iterate through and then create a datasource. When you execute the web test, it will iterate through all of the items in the CSV file, one line for each test execution.

Based on what you outlined above I would probably create 2 tests and 2 CSV files. One test would be a test where the login is successful and it would have a list of valid usernames and passwords and the second test would be for invalid logins.

An alternative would be to have a single test and in the CSV have 3 columns, user name|password|expectedResponse. You could then create a validation rule that looks for the value in the expectedResponse column and passes so long as it matches. A single test would work fine, but the reporting would probably be cleaner with two test cases.

share|improve this answer
1  
thank you very much. –  Anicho Oct 31 '12 at 11:19
add comment

web test Plugins was my solution I can write some code to iterate or go through a data set quite easily. Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.WebTesting;

namespace SampleRequestPlugins
{
    public class DynamicUsername : WebTestPlugin
    {
        static int _testIterationNumber = 1;

        public override void PostWebTest(object sender, PostWebTestEventArgs e)
        {
            e.WebTest.Context["TestIterationNumber"] = _testIterationNumber;
            _testIterationNumber++;
        }

        public override void PreWebTest(object sender, PreWebTestEventArgs e)
        {
            e.WebTest.Context["username"] = "username" + _testIterationNumber.ToString();
        }
    }
}

I created a new class library with the above class. I then referenced the class library project in my test project, I could then right click on the top node of a web test and add as a web test plugin.

share|improve this answer
add comment

I also suggest reading these great MSDN docs:

Binding a Data Source to a Web Performance Test

How to: Set Credentials on a Web Performance Test

You can set the credentials for any Web site that uses basic authentication or Integrated Windows authentication. Web sites that contain personal information often require user authentication before displaying any information through the browser. By setting the credentials for a Web performance test, you can conduct tests on sites that require this level of authentication. You set credentials in Web performance tests in the Web Performance Test Editor. For more information about how to edit a Web performance test, see How to: Edit an Existing Web Performance Test Using the Web Performance Test Editor.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.