Calling VS 2005 tests from Windows forms test harness

I like VS 2005 Team System ability to generate test cases. Using it with TestDriven.Net “Test with Debugger” allows quickly debug and test a new or existing code.
However if you do a relatively long debugger session with multiple edit changes, the test session is often interrupted.

I found that “Edit and Continue” for Windows form(or console) application is more stable. 
So my question was: can I call TestMethod from Windows form test harness?

The answer is YES, no problem.
You need to add reference to your TestCases Project( just as any other class library) and call required methods from Windows form.By the way, the same approuact will work wit NUnit as well.
For example:

      private void btnImportTest_Click(object sender, EventArgs e)

        {

            try
            {
            MyClassTest test = new MyClassTest();
            test.MyMethodTest();
            }
            catch (Exception exc)
            {
                 Debug.WriteLine(exc.ToString());
                 MessageBox.Show(exc.ToString());
            }

       

By putting the call inside try block allow you to restart your test many times without re-compile, and using Debug.WriteLine shows exception details, including line number to output window, which is easy to navigate to set breakpoints.  

}

posted @ Thursday, July 06, 2006 3:57 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345