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.
}