-
Notifications
You must be signed in to change notification settings - Fork 131
MsTest DataDriven tests from Xml and CSV files
Jakub Raczek edited this page Apr 25, 2019
·
4 revisions
Data driven tests from Xml or Csv files are supported with MSTest by default.
<?xml version="1.0" encoding="utf-8" ?>
<Rows>
<Links>
<number>5</number>
</Links>
<credential>
<user>tomsmith</user>
<password>SuperSecretPassword!</password>
<message>You logged into a secure area!</message>
</credential>
<credential>
<user>wronguser</user>
<password>wrongpassword</password>
<message>Your username is invalid!</message>
</credential>
</Rows>
namespace Ocaramba.Tests.MsTest.Tests
{
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ocaramba;
using Ocaramba.Extensions;
using Ocaramba.Tests.PageObjects.PageObjects.TheInternet;
[TestClass]
public class HerokuappTestsMsTest : ProjectTestBase
{
[DeploymentItem("Ocaramba.MsTests\\DDT.xml"),
DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
"|DataDirectory|\\DDT.xml", "credential",
DataAccessMethod.Sequential), TestMethod]
public void FormAuthenticationPageTest()
{
new InternetPage(this.DriverContext).OpenHomePage().GoToFormAuthenticationPage();
var formFormAuthentication = new FormAuthenticationPage(this.DriverContext);
formFormAuthentication.EnterUserName((string)this.TestContext.DataRow["user"]);
formFormAuthentication.EnterPassword((string)this.TestContext.DataRow["password"]);
formFormAuthentication.LogOn();
Assert.AreEqual((string)this.TestContext.DataRow["message"], formFormAuthentication.GetMessage);
}
}
}
user, password, message
tomsmith,SuperSecretPassword!,You logged into a secure area!
wronguser,wrongpassword,Your username is invalid!
[DeploymentItem("Ocaramba.MsTests\\DDT.csv")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\DDT.csv", "DDT#csv", DataAccessMethod.Sequential)]
[TestMethod]
public void FormAuthenticationPageCsvDataDrivenTest()
{
var formFormAuthentication = new InternetPage(this.DriverContext)
.OpenHomePage()
.GoToFormAuthenticationPage();
formFormAuthentication.EnterUserName((string)this.TestContext.DataRow["user"]);
formFormAuthentication.EnterPassword((string)this.TestContext.DataRow["password"]);
formFormAuthentication.LogOn();
Verify.That(
this.DriverContext,
() => Assert.AreEqual((string)this.TestContext.DataRow["message"], formFormAuthentication.GetMessage));
}
- Home
- Getting started
- Parallel tests execution
- MsTest DataDriven tests from Xml and CSV files
- NUnit DataDriven tests from Xml, CSV and Excel files
- Comparing files by NUnit DataDriven tests
- Visual Testing
- Screen shots: full desktop, selenium. PageSource saving
- Verify-asserts without stop tests
- Downloading files
- Helpers
- Override browser profile preferences, install browser extensions, Headless mode
- Debugging Test.Automation framework
- Logging
- Performance measures
- Webdriver Extends
- More common locators
- Selenium-Grid-support
- Advanced Browser Capabilities and Options
- AngularJS synchronization
- Update App.config or appsettings.json
- Cross browser parallel test execution with testing-Cloud-Providers\SeleniumGrid
- Verifying Javascript Errors from browser
- Enabling Performance Log for Chrome
- Azure DevOps Support
- Edge browser Support
- Downloading and running Selenium Grid with Powershell
- Run Ocaramba tests with Docker container
- HTTP auth in Internet explorer
- ExtentReports Support