NUnit: Accessing the Failure Message in TearDown()

前端 未结 3 1352
悲哀的现实
悲哀的现实 2020-12-18 12:48

I\'m trying to log the results of automated tests run in NUnit in a small database so that data is easily accessible and more securely logged for various reasons. (There\'s

3条回答
  •  Happy的楠姐
    2020-12-18 13:24

    I believe you'll be able to get the information you need with NUnit EventListeners. I haven't used these myself, but I've had them bookmarked to do something similar to what you're trying to accomplish.

    Here's the interface you'd be working with. Hopefully your TearDown method would be called just before TestFinished, but I can't verify this.

    public interface EventListener
    {
        void RunStarted(string name, int testCount );
        void RunFinished(TestResult result);
        void RunFinished(Exception exception);
        void TestStarted(TestName testName);
        void TestFinished(TestResult result);
        void SuiteStarted(TestName testName);
        void SuiteFinished(TestResult result);
        void UnhandledException(Exception exception);
        void TestOutput(TestOutput testOutput);
    }
    

提交回复
热议问题