I am using Gauge from Thoughtworks to Automate my UI Tests. Every time that an assert fails in my tests it lists the message indicated in the assert.
For example when this code fails from Scenario #1
Assert.True(listsMatch, "There are differences between the Test Dropdown List on the Report Template Editor page and the reference list");
This message goes to the Gauge Automation report in Scenario #1 report
There are differences between the Test Dropdown List on the Report Template Editor page and the reference list
Expected: True
But was: False
The issue comes when the next assert fails (in the next scenario) that all of the messages for the previous assert failures are all listed (for both of the failed scenarios) instead of just the new one (for the second failed scenario). For example the output would look like this, with the previously failed asserts message from scenario #1 listed below as "2)", and the currently failed asserts message from scenario #2 listed below as "1)"
Multiple failures or warnings in test:
1) The OK button was not visible to click on after 6 seconds
Expected: True
But was: False
2) There are differences between the Test Dropdown List on the Report Template Editor page and the reference list
Expected: True
But was: False
How do I only get the new assert message to be output to the report? Is there a way to do this?
I haven't been able to see any possible solutions for this
What I would expect is that for any given assert only the message related to that assert would be output to the Gauge Automation report instead of having a list of every failure in all tests run.
One additional detail that I thought of is that the asserts are in different scenarios.
Requested code examples (Note this is example code to illustrate the distributed nature of the Asserts. I think that I've caught most minor issues in making the example, but if I've missed defining a variable or something minor realize this is just an example, not the actual code I run): '''c#
class Steps_Button_OK
{
[Step("Click the OK button")]
public void Click()
{
double waitCount = 0;
int maxWait = 5;
int waitInterval = 1;
int numOfElements = 0;
// This for loop is made to poll to see if the elements have loaded yet.
do
{
numOfElements = ButtonWebElementList.Count;
if (numOfElements > 0)
{
break;
}
else
{
waitCount += waitInterval;
DriverExtensions.WaitXSeconds(waitInterval);
}
} while (numOfElements <= 0 && waitCount < maxWait);
if (waitCount >= maxWait)
{
GaugeMessages.WriteMessage("The {0} button was NOT found under the maximum wait time of {1} seconds.", this.ButtonDescriptor, maxWait);
screenshotsteps.TakeFullScreenshotAndWriteStep("Exception");
Assert.True(false);
}
if (logging)
{
GaugeMessages.WriteMessage("The {0} button was found at {1} seconds.", this.ButtonDescriptor, waitCount);
}
ButtonWebElement.Click();
}
}
class Steps_Test_Dropdown
{
[Step("Verify Lists Match")]
public void OptionsMatchListInScenStore()
{
PO_BasePageObject_SelectDropdown _selectDropdownElement = new PO_BasePageObject_SelectDropdown();
string scenarioStoreVariable = "OldList";
int maxWait = 5;
double waitInterval = 1;
bool listsMatch = true;
IList<string> oldStringList = (IList<string>)scenarioStore.Get(scenarioStoreVariable);
_selectDropdownElement.Options_WaitToExist(maxWait, waitInterval);
IList<string> dropdownTextList = _selectDropdownElement.Options_ValidList();
int oldLength = oldStringList.Count;
int drpdwnLength = dropdownTextList.Count;
// Make sure all of the dropdown text values are in the reference (old) String list
foreach (string feString in dropdownTextList)
{
if (!oldStringList.Contains(feString))
{
listsMatch = false;
GaugeMessages.WriteMessage("- The value {0} is in the {1} dropdown list but not in the reference list", feString, _selectDropdownElement.SelectDescriptor);
}
}
// Make sure all of the reference (old) list text values are in the Test dropdown list
foreach (string feString in oldStringList)
{
if (!dropdownTextList.Contains(feString))
{
listsMatch = false;
GaugeMessages.WriteMessage("- The value {0} is in the reference list but not in the {1} dropdown list", feString, _selectDropdownElement.SelectDescriptor);
}
}
GaugeMessages.WriteMessage("There are {0} tests listed in the {1} Dropdown", drpdwnLength, _selectDropdownElement.SelectDescriptor);
GaugeMessages.WriteMessage("There are {0} tests listed in the reference list", oldLength);
// Assert to check that the lists match (or don't)
Assert.True(listsMatch, "There are differences between the {0} Dropdown List and the reference list", _selectDropdownElement.SelectDescriptor);
}
}
'''