Nunit error log repeating exceptions - Multiple failures or warnings in test

Asked

Viewed 96 times

0

I am using Nunit to run test scripts with Selenium Webdriver in C# (Visual Studio). The project uses the template Console Application.

When running, the project displays a console (prompt) where I tell you which test environment and which test scripts will be run in sequence (1 or more).

During execution, if a Assert of the failed test script, a log file is generated .txt that records the exception error. Then the next test runs until the tests of the queue are completed.

Problem: if another queue test fails, Nunit lists again in the log the previous test error plus the new error, and so on, enumerating the errors.

Log of Test 1:

There are differences between the Test Dropdown List on the Report Template Editor page and the reference list

  Expected: True
  But was:  False

Log of Test 2:

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

Excerpt that generates the log file:

StreamWriter sw = new StreamWriter("LogExecucao" + ".txt", true);

try
{
    //scripts de teste
}
catch (Exception ex)
{
    sw.WriteLine(ex.Message);
}

The same problem was reported at this link, but had no definitive answer. In this case, the user used the tool Gauge of Thoughtworks:

Someone in the community knows a way to record the exceptions without Nunit repeating them?

1 answer

0

I know it’s been a while since the question was asked but I found the topic interesting.

I believe the error must be because of the Selenium Web Driver (+ Nunit). I made a simple implementation of a console that has a method that returns an exception.

If the error mentioning my text file occurred it should look like this:

1
1
2
1
2
3

But it was as expected:

1
2
3

Follow print of my implementation: inserir a descrição da imagem aqui

PS: I could not comment on the question because I have no reputation in the OS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.