Sunday, March 29, 2009

Use Reporter Annotations

Today I implemented a bit of dependency injection for the reporters in the Java version of approvaltests.

The idea is that you might want your own reporters for your project. Things to take advantage of something we didn’t think of. While you could have always done this by calling:


Approvals.approve(ApprovalWriter,
ApprovalNamer,
ApprovalFailureReporter)


I wanted to make it a wee bit easier.

Now you can do it by adding an annotation to any level of the stack calling. For example:


@UseReporter(FailedQuietApprovalReport.class)
public class MyQuietTest extends TestCase
{
public void testSomethingQuiet()
{
}
@UseReporter(FailedDiffTextApprovalReport.class)
public void testWithDiff()
{
}
}

This should make it easier in Java, and will probably appear soon in c#. You can download it now as part of

ApprovalTests Current 0.0.004

No comments: