Search code examples
debuggingmstestbreakpoints

Visual Studio MSTest doesn't stop on breakpoint when [ClassInitialize] tag present


On my first MSTest project (VS2015) I encountered the following problem, if I have

    [ClassInitialize]
    public void Exe20_Run()
    {
    }

The debugger doesn't stops on breakpoints. The debugger will stop on breakpoints if I change it to

    [TestInitialize]
    public void Exe20_Run()
    {
    }

So, I guess that for some reason, the [ClassInitialize] damages the debugger functionality... I need the [ClassInitialize] but also debugging capability is wanted.

Could you please help?

Thanks, Liat


Solution

  • For [ClassInitialise] you don't have the correct signature. Try the following:

        [ClassInitialize]
        public static void Exe20_Run(TestContext t)
        {
            System.Console.WriteLine("YO!");
        }
    

    Add your breakpoint, go to Test menu -> "debug all tests" (or CTRL-R, CTRL-A) and it should stop.