Chaining Tests
August 10, 2010 Leave a comment
I learned something new about tests this morning. Methods that are called from a test that have an Assert in them will be treated as a test. For example:
InterfaceKit interfaceKit = null;
[TestMethod()]
public void InterfaceKitAttachedTest_ReturnsTrue()
{
interfaceKit = new InterfaceKit();
interfaceKit.Attach += new Events.AttachEventHandler(interfaceKit_Attach);
interfaceKit.open();
}
void interfaceKit_Attach(object sender, Events.AttachEventArgs e)
{
bool expected = true;
bool actual = interfaceKit.Attached;
Assert.AreEqual(expected, actual);
interfaceKit.close();
}
Thinking about it, that makes sense – b/c the called method is sharing the stack so the Assert will be called and inspected.