Wednesday, June 18, 2014

What's new in ApprovalTests.Net v3.6

I finally got a new version released. It's been a lot time in the making and I wanted to highlight some of the new feature. There's a bunch so hold on tight:


One issue that pops up with approvals is sometimes old approval files end up abandoned in the source tree. Now you can write a simple test that will prevent this

Asp Scrubbers

It's great that ApprovalTests can so easily capture web pages, but it can still be hard to get those pages as consistent as a Unit test needs them to be. Inspired by Geoff Bache's TextTest, scrubbers have been included.

Scrubbers are simple Functions that take a input string and return a clean version of it. Here's an example to remove the GUID used by asp for forms


SimpleLogger is a easy way to both capture behavior for locking test as well as see performance data for simple profiling but it was also hard to get everywhere a method would exit. Now you don't have to, simply use a using around the method like this.


Locking down legacy code can be hard when none of the objects have a good ToString. Enter StatePrinterApprovals. Using the nuget package StatePrinter you can easily print and capture even highly complex and recursive object graphs.

Rest Calls 

Finally there is a simple object to create your own Rest Calls that are both easy to Mock (because they implement ILoader) and easy to Test. Here's the Testing Logic
and here the code to test it.


It's always been easy to verifyJson, but now it will be pretty printed as well

Serializable Theory Test

Using Theory based testing, you can now test that any object can be serialized and consumed to recreate the original object. It's as simple as 


You can also easily assert that WindowsRegistry Values are in place with


ApprovalTests is more extensible with the introduction of WriteFactory. An easy way to insert your own FileWriters if you need them


Finally, the last big change is the introduction of DataScenarios. This allows you to use data driven test cases to produce multi approved files.

No comments: