Is it possible to nest TestMethods in ClassCleanup and have them run/behave as TestMethods instead of regular method calls?
I have a TestClass to test an AppMngr class I created to manage a process. I test for the ability to Open/Close the app (e.g. MyNotepadMngrClass.Open() and …Close()). I have several more classes that do work inside that process (e.g. MyNotepadWorkerClass.WriteLine() or …DoSomething() ). When testing the other classes I need to start notepad and close it when done. ClassInitialize/ClassCleanup are obvious places for this. But I want to confirm notepad closed.
So I created a static [TestMethod] for the Close operation. I call it from ClassCleanup in MyNotepadWorkerTestClass. It performs the close operation fine. But if I add something like — Assert.IsFalse(true); — to the body of my close method the test run does not fail.
Let me know if what I am trying to do fundamentally wrong. Appreciate any you can give help.
P.S. Hey TestStand guys, I am looking for Setup/Ceanup behaviour during RunSelectedStep. TestDriven.NET gives me RunSelectedStep. So how do I catch failures during ClassInitialize and ClassCleanup.
ClassCleanup is by definition to be used “after all the tests in the test class have run” (from msdn), so you probably can’t add new test methods in there. You’ll need to restructure your test.