How to diagnose “TestFixtureSetUp Failed”

前端 未结 11 1111
感动是毒
感动是毒 2021-02-06 21:46

We use TeamCity as our CI server, and I\'ve just started seeing \"TestFixtureSetUp Failed\" in the test failure window.

Any idea how I go about debugging th

11条回答
  •  误落风尘
    2021-02-06 22:14

    In case it can help someone: You can catch the exception and write it in the console on the TearDown

    Something like :

    [SetUpFixture]
    public class BaseTest
    {
        private Exception caughtException = null;
    
        [SetUp]
        public void RunBeforeAnyTests()
        {
            try
            {
                throw new Exception("On purpose");
            }
            catch (Exception ex)
            {
                caughtException = ex;               
            }
        }
    
        [TearDown]
        public void RunAfterAnyTests()
        {
            if (caughtException != null)
            {
                Console.WriteLine(string.Format("TestFixtureSetUp failed in {0} - {1}", this.GetType(), caughtException.Message));
            }           
        }
    
    }
    

    And the result will be :

    TestFixtureSetUp failed in IntegratedTests.Services.BaseTest - On purpose

提交回复
热议问题