简体   繁体   中英

CUIT - Data Driven iteration at step level within the same test method

I'm new to CUIT and I'm trying to create a data driven test that goes through numerous iterations in one go. I currently have it so that it Opens the browser, enters log in values,click sign in and closes the browser, then open a browser and start again.

I want it to Open the browser, enter log in values, click sign in, re-enter log in values, click sign in, re-enter log in values, click sign in, close the browser.

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "C:\\Visual Studio 2012\\Projects\\CodedUITestProject2\\MedProvisionInvalidLogIn.csv", "WebsiteInvalidLogIn#csv", DataAccessMethod.Sequential), DeploymentItem("WebsiteInvalidLogIn.csv"), TestMethod]

public void WebsiteInvalidLogIn()
{
    this.UIMap.OpenWebsite();
    this.UIMap.TypeUserNameParams.UIUserNameEditText = TestContext.DataRow["UserNameValue"].ToString();
    this.UIMap.TypeUserName();
    this.UIMap.TypePasswordParams.UIPasswordEditPassword = Playback.EncryptText(TestContext.DataRow["PasswordValue"].ToString());
    this.UIMap.TypePassword();
    this.UIMap.ClickSignIn();
    this.UIMap.AssertSignInEnabled();
}

How would I go about this? I tried copying all the lines and pasting them in a second time(before the assert) but it didn't work. It only moves to the next iteration when it completes the sign in.

Best solution would be to make a TestInit and a TestCleanup testmethod, and put them in an ordered test with your data driven test. This way you will have separate test results for separate data rows.

TestInit - opens browser

WebsiteInvalidLogIn - the data driven test

TestCleanup - closes the browser

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