问题
Whenever an NUnit test fails during its execution (i.e. not when using Assert.*
), I want to log additional information (I'm writing web tests and I am especially interested in the web page's current DOM).
How to specify a global exception handler in NUnit which is able to log additional information on NoSuchElementException
s - test should still fail of course.
回答1:
You could write an NUnit event listener addin that logs the information. See http://www.nunit.org/index.php?p=nunitAddins&r=2.6.3 and http://www.nunit.org/index.php?p=eventListeners&r=2.6.3. For a tutorial, see https://www.simple-talk.com/dotnet/.net-tools/testing-times-ahead-extending-nunit/.
来源:https://stackoverflow.com/questions/24888492/additional-log-output-on-nunit-test-fail