0

If I have recorded an asseetion from VS2013 coded ui test recorder. The assertion verifies Things like,

  • The name Field containst "Jeff" as name
  • His age is "60" in age field or not

Now, let's say I already have a data.csv Connected and configured to solution. All I want to do now is to replace the assertion vlaue JEFF and 60 from certain values from my CSV file.

This is the code in background for assertion

Assert.AreEqual(this.name_assertionExpectedValues.UIEierPane1HelpText, uInamePane1.HelpText, "Cant find Name text label");

Can you tell me what will parametering look like in main CS file for this.

Just so that instead of comparing the expected value from my CSV file not the recorded string.

Thanks in advance.

Firaun
  • 369
  • 1
  • 5
  • 21
  • possible duplicate of [How to run a test many times with data read from .csv file (data driving)](http://stackoverflow.com/questions/23469100/how-to-run-a-test-many-times-with-data-read-from-csv-file-data-driving) . See the words about `CheckResultExpectedValues`. – AdrianHHH Jul 29 '15 at 08:27

2 Answers2

2

you can write code as below

Assert.AreEqual(TestContext.DataRow["Name"].ToString(),uInamePane1.HelpText, "Cant find Name text label");

here "Name" will map to your data source Name Column.

Kuldeep Vasani
  • 310
  • 1
  • 3
  • 13
  • I think this wont change his recorded method which still asserts on the hard coded value thus his test will probably fail before reaching the new assertion – barakcaf Jul 29 '15 at 14:05
0

The recorded Assertion in the UI Map file contains the values and this will generate an assertion method, so your assertion code should look like something like this:

this.UIMap.NameOfYourAssertion();

This will assert on the value you recorded. Now when you want to change the value of what you recorded you change the value of the assertion as follows:

this.UIMap.NameOfYourAssertionExpectedValues.UIYourEditBoxText = "your value from csv";

So for every assertion with the name there will be a property of the type that is expected. Most likely a string value. By changing the value before you call the assert method it will then use the changed value. You can use the TestContext.DataRow["Name"].ToString(); call to get the data from the CSV file if you added it to the test method using the DataSource attribute on the test method as described here in MSDN: https://msdn.microsoft.com/en-us/library/ms182519.aspx