This scenario covers to test between html values and static values in CSV.
- Test target : http://en.wikipedia.org/wiki/United_States
- Test project : samples/SampleTest/SampleTest.csproj
- Test spreadsheet : https://docs.google.com/spreadsheets/d/1Gvnq2NlBXyrnsjBH0Xr-R8U0f9RLeCR9RH5eAdTL_XE/edit?usp=sharing
- CSV download link: https://docs.google.com/spreadsheets/d/1Gvnq2NlBXyrnsjBH0Xr-R8U0f9RLeCR9RH5eAdTL_XE/export?format=csv&id=1Gvnq2NlBXyrnsjBH0Xr-R8U0f9RLeCR9RH5eAdTL_XE&gid=0
- Get a actual html document from Web App.
- Assert HTTP response header and/or document values using expected values in CSV file.
- Create a test project.
- Install Tatami library from nuget.org then sets this into the project.
- Create a BaseUriMapping.xml
- See more details : BaseUriMapping.xml settings
- Create a UserAgentMapping.xml
- See more details : UserAgentMapping.xml settings
- Create a CSV file including test cases.
- Create a test method.
- Run test.
[TestMethod]
public async Task TestWikipediaWithUnitedStatesPage()
{
// Arrange
var testCasesCsv = await new HttpClient().GetStringAsync(
"https://docs.google.com/spreadsheets/d/1Gvnq2NlBXyrnsjBH0Xr-R8U0f9RLeCR9RH5eAdTL_XE/export?format=csv&id=1Gvnq2NlBXyrnsjBH0Xr-R8U0f9RLeCR9RH5eAdTL_XE&gid=0");
var baseUriMappingXml = File.ReadAllText(@"Wikipedia\BaseUriMapping.xml");
var userAgentMappingXml = File.ReadAllText(@"UserAgentMapping.xml");
var testExecutor = new TestExecutor(testCasesCsv, baseUriMappingXml, userAgentMappingXml);
// Act
var result = await testExecutor.TestAsync();
// Assert
if (!string.IsNullOrWhiteSpace(result.FailedMessage))
{
Assert.Fail(result.FailedMessage);
}
}