Decorator feature enhancement
[Cross Posted in TypeMock Insider Blog]
Typemock-Isolator has a little know Decorator feature that allows developers to simply add capabilities to their test framework (all test framework).
Using this feature Typemock-Isolator creates the [VerifyMocks] decorator that automatically verifies the mocks at the end of your tests.
To create a custom decorator simply extend the DecoratorAttribute and implement the Execute method.
public override object Execute()
{
// Trace start of method
Console.WriteLine(“Entering Method:”+
OriginalMethod.ToString());
// Execute the original method
return base.CallDecoratedMethod();
}
To support multiple decorators on the same test method, Typemock-Isolator makes sure that even if a developer forgot to call CallDecoratedMethod() the test method will still run. This is done by calling the decorated method if it wasn’t explicitly called.
We discovered that some Decorator implementers want more control and need to explicitly make sure that the test method was NOT called.
A new API was added in version 4.2 to do just that.
Once this is called (inside Execute), the decorator mechanism will not call the test method.
Of course if there is another decorator on the test method that calls CallDecoratedMethod() the test method will be executed.
Recent Posts
- Product Status Peek – 2011
- Thanks Roy
- Typemock starts 2011 in a new location
- Agile Demos Smells
- I want loud disputes in our meetings
Categories
- .NET Tests
- Agile
- Code Integrity
- Community
- Debugging
- Fun
- Management for Geeks
- Marketing
- Product
- Release
- Reviews
- SharePoint
- TDD
- Time Management
- Uncategorized
- Unit Tests
Archives
- January 2011
- December 2010
- October 2010
- August 2010
- May 2010
- April 2010
- March 2010
- February 2010
- December 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- December 2008
- November 2008
- August 2008
- July 2008
- May 2008
- April 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
