Sorry for such a loooong post!!
I am brand new to coding/automated testing. I have VS 2013 Ultimate and created a CodedUI test with an assertion and it runs fine. However, when the assertion fails, the test stops. I know this question has been asked many times and I have tried the solutions shown but am having no luck. I want the test to run even after the failure occurs.
I am testing a .net application, in the app we have several search fields, I want to verify that if I search for the word 'test' that the search result will have the word 'test' in it. I did an assertion on a cell that did not have the word 'test' in it and as expected, the assert failed.
I want the test to continue running so that I can search all the other fields but it stops as soon as the assert fails.
When I did the assert on the cell I used 'Contains' and not 'AreEqual' seemed to make sense since I am looking for 'test' in any part of the address (even if it said something like '1 wetester dr')
here is the part of the code from the codedUITest1.cs script:
//From the CodedUITest1.cs file
[TestMethod]
public void TestAddressSearchFields()
{
this.UIMap.SearchAddressFor_test();
this.UIMap.Assert_on_FirstAddressCellForTheWord_test();
this.UIMap.SearchNextThing();
this.UIMap.SearchAnotherThing();
}
---------------------------------------------------------------------------------------
// From the UIMap.Designer.cs file (this is the definition for the assert)
public void Assert_on_FirstAddressCellForTheWord_test()
{
#region Variable Declarations
WinCell uIItem800SROLLINGRDCell = this.UIDPSClaimantSearchWindow.UIGrdClaimantSearchWindow.UIDataGridViewTable.UIRow6Row.UIItem800SROLLINGRDCell;
#endregion
// Verify that the 'Value' property of '800 S ROLLING RD' cell contains 'test'
StringAssert.Contains(uIItem800SROLLINGRDCell.Value, this.Assert_on_FirstAddressCellForTheWord_testExpectedValues.UIItem800SROLLINGRDCellValue, "Address does not contain the word \"test\"");
}
//And then the definition for the cell value
[GeneratedCode("Coded UITest Builder", "12.0.30501.0")]
public class Assert_on_FirstAddressCellForTheWord_testExpectedValues
{
#region Fields
/// <summary>
/// Verify that the 'Value' property of '800 S ROLLING RD' cell contains 'test'
/// </summary>
public string UIItem800SROLLINGRDCellValue = "test";
#endregion
}
I tried the following but it didn't work, once the assertion failed, the test stopped (is it because the failure is not an exception?)
this.UIMap.SearchAddressFor_test();
try
{
this.UIMap.Assert_on_FirstAddressCellForTheWord_test();
}
catch (Exception theword_test_not_found)
{
throw (theword_test_not_found);
}
{
Playback.PlaybackSettings.ContinueOnError = true;
}
Sorry for such a long post, remember I am brand new to this, please be gentle!