Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTEST - Continuing after an Assert has failed

I am wonder if there is an easy way to finish a test after an Assert has failed. We used to use Galileo for all of our automated tested, but we have moved the Visual Studio Test framework. We had a method that would allow a test to fail, but continue on.

        public static bool DoAssertAndContinue(Action assert)
    {
        try
        {
            assert();
            return true;
        }
        catch (AssertionException ae)
        {
            ConfigContext.WriteLine(ae.Message);
            return false;
        }
    }

This is what we used before...and it would be called like this:

assertionResults.Add(Automation.Utils.CommonMethods.DoAssertAndContinue(() => Assert.IsTrue(detail.ValidateName(boo, urns))));

I am just trying to figure out the best way to emulate what we had before without having to refactor all of our tests.

like image 778
Woundedbear Avatar asked Feb 14 '12 22:02

Woundedbear


1 Answers

Instead of AssertionException, you should now catch UnitTestAssertException which is the base exception for all mstest assert failures.

like image 111
Aseem Bansal Avatar answered Oct 16 '22 04:10

Aseem Bansal