Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
3 years ago

Updating Log.ErrCount value

Hi folks,

 

I have a requirement to fail the gherkin scenario in the Then statement, if the scenario has any Log.Error posted to the test log. I tried using Log.ErrCount, but the problem is that it counts errors from the all scenarios in the feature. While, I am looking for a way to count errors just within each individual scenario. If I can somehow update the value of Log.ErrCount to 0 after each scenario run, it will fulfil the requirement as every scenario will then start Log.ErrCount from the scratch, by not considering the past scenarios errors count.

 

Any help please!

 

function ErrCount()
{
var ErrCount = Log.ErrCount;

if ( ErrCount > 0 ){
Log.Message("There is(are) " + ErrCount + " error(s) in the scenario.")
Log.Error("Scenario failed with some errors.");
}
else
Log.Checkpoint("Scenario passed without any errors.");
}

 

Thanks in advance,