Question

I have Visual Studio web test attached nicely to a data source, but I need to be able to iterate over each entry in the data source. How should I do this?

Was it helpful?

Solution

This article seems to Discuss something quite like what you're talking about. Good luck. Ola

EDIT: From the linked article, your DataSource is exposed to your test via an attribute.

[DataSource("System.Data.SqlClient",
    "Data Source=VSTS;Initial Catalog=ContactManagerWebTest;
    Integrated Security=True", "ValidContactInfo",
    DataAccessMethod.Sequential), TestMethod()]

There are several other DataSources you can link to, for example CSV, or even Parameters of a Test Case in TFS. Be sure to include the DataAccessMethod.Sequential. If there are multiple rows in the table indicated by the DataSourceAttribute, then each test run will have TestContext.DataRow pointing to the current row/iteration for the test.

OTHER TIPS

The trick is to select "Run test(pause before starting)"

Then when the test opens up, click the little link that says "Edit run settings"

A dialog boxes opens allowing you to choose "One run per datasource row"

Open Local.testsettings file from solution explorer and go to Web Test -> Select "One run per data source now" option. That's it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top