简体   繁体   中英

how to get nunit results to a database

Hi I am trying to get the nunit results into a database while it is running. So what I really need is a way to see if the test has passed or failed on the teardown so that I can write some code to insert values into the database based on if it passes or fails.

So is it possible to get this information in the teardown if the current running test is in a passing or failing state, as well as information such as test name and if it has failed the reason for failure.

Thanks

In NUnit at or post 2.4.4, you can get the TestResult as it happens using EventListeners - you need to write your results to the DB from the TestFinished method.

void TestFinished(TestResult result);

The name of the test will be that of the most recent TestStarted call:

void TestStarted(TestName testName);

To do this you have to implement an NUnit addin that implements the EventListeners interface.

Do you want to see results as they happen, or at the end? If you just want to see them at the end, you could get NUnit to write them to an XML file:

nunit-console /xml:console-test.xml nunit.tests.dll

You could then write a program to parse the XML and load it into a database.

To see test results as they happen, you could write your own NUnit log plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM