Is it possible to run code after all tests finish executing in MStest

前端 未结 4 742
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 01:28

I am writing coded ui tests and I have the application open if it is not already open. Then if one of them fails I close the application the thing is I have multiple tests in mu

4条回答
  •  孤独总比滥情好
    2021-02-04 01:46

    IMPORTANT

    Someone who is using base class can do assembly cleanup there as well

    [TestClass]
    public class Page : PageContract, IWindowControlAccess
    {
    [AssemblyCleanup()]
        public static void ApplicationCleanup()
        {
            Cleanup();
        }
    }
    

    Two important things here 1. [TestClass] attribute at the base is MANDATORY

    2. signature of ApplicationCleanup see its a static method

    That's it you are done. I had hard time struggling and debugging it.

提交回复
热议问题