Thursday, July 3, 2014

What's new in ApprovalTests.Net v3.7

[Available on Nuget]

AsyncApprovals - rules and exceptions

[Contributors: James Counts]
In the end, all tests become synchronous. This means for a normal test we recommend
However, If you are looking to test exceptions everything changes and you might want to use

Removed BCL requirement

[Contributors: James Counts &  Simon Cropp]
HttpClient is nice way of doing web calls in .Net. Unfortunately, at this time the BCL in nuget does unfortunate things to your project if you do not wish to use the HttpClient. 
This is a violation of a core philosophy of approvaltests 

"only pay for the dependencies you use

HttpClient was add ApprovalTests 3.6. Thanks to Simon for pointing and troubleshooting this error. It has now been removed. 

Wpf Binding Asserts

[Contributors: Jay Bazuzi]
This is a bonus from v3.6
It is a very hard thing to detect and report Wpf Binding Error. To even get the reports to happen you have to fiddle with the registry and then read and parse logs.
No More!  Now to you use BindsWithoutError to ensure that your Wpf binding are working.


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:

VerifyNoAbandonedFiles

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

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.


StatePrinterApprovals

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.


VerifyJson

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 


WindowRegistry.Asserts

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


WriterFactory

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

ApprovalDataScenarios

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