Saturday, December 31, 2011

Using Reporters in Approval Tests

Today I pushed new versions of ApprovalTests for both C# and Java to SourceForge.  Updates include new capabilities around the Reporters feature set for ApprovalTests. These enhancements were driven by feature requests from  Peik Aschan(@peikas).  He and I pair-programmed remotely (he lives in Finland) to extend ApprovalTests per his ‘asks’.  If you are using ApprovalTests and have an idea for a feature, please ping me via twitter @LlewellynFalco and I’ll pair with you to code up your idea as well.

Why Use Reporters?

I assume that you have tried out Reporters if you are reading this blog, however, just to get us started, I’ll remind you that a Reporter is called when an ApprovalTest fails.  The three reasons for using different types of reporters are as below.

Visualizing Results

The output of a failed  ApprovalTest can range from simple (a text file) to complex (*.png, *.html, *.mp3, etc…)  If you get a *.html file, then you do not usually want to see the ‘page source’ output, rather you can usually more easily view (and approve) a HTML-rendered view.  Because of this, you might want to decorate your class or method with
[UseReporter(typeof(FileLauncherReporter))]

image


Comparing Results

Of course, not only do ApprovalTests Reporters tell you the results, but also the results can help you determine what has changed since they last passed.  While the screenshot above will help you to understand what the web page LOOKS like, it won’t help you to figure out why the test is no longer passing.  To get more granular information, you may want to use a different Reporter, such as the DiffReporter.  Output is shown below.

[UseReporter(typeof(DiffReporter))]

image

Approving the Results

The last reason to use a particular Reporter is to make the ability for you to approve the dersired output of the test easier.  The DiffReporter is most often used for this, because you can just right click in your particular differencing tool (TortoiseMerge is shown above, BeyondCompare, WinMerge or KDiff can also be used) and approve the output ‘approve whole file’. 

In this release of ApprovalTests, I’ve added a new reporter to increase the flexibility of approving.  That reporter is called the ClipboardReporter and here is how it works.  Rather than launching the output in any tool, this reporter creates the command-line output needed so that you can move the results file to the approved file quickly.  It automatically adds this command to your clipboard:

[UseReporter(typeof(ClipboardReporter))]

image

Simply open a command prompt and past the contents of the clipboard in to the command prompt window to approve the file.


How to use Reporters


In the release, we have added the ability to decorate an assembly (C# only), class or method with multiple reporters.  This is easy to do, just add the reporters of interest to the level, separated by commas.  The current list of reporters is as follows:

C# Reporters Java Reporters
BeyondCompareReporter.cs
ClipboardReporter.cs
DiffReporter.cs
FileLauncherReporter.cs
ImageReporter.cs
MsTestReporter.cs
MultiReporter.cs
NotepadLauncher.cs
NUnitReporter.cs
QuietReporter.cs
WinMergeReporter.cs
ClipboardReporter.java
DiffReporter.java
EnvironmentAwareReporter.java
ExecutableQueryFailure.java
FileLauncherReporter.java
FirstWorkingReporterChain.java
GenericDiffReporter.java
ImageDiffReporter.java
ImageWebReporter.java
JunitReporter.java
MultiReporter.java
NotePadLancher.java
QuietReporter.java
TextWebReporter.java
TortoiseDiffReporter.java
WinMergeReporter.java


Here is the code example for the scenario described above, i.e. both HTML (browser) and Diff (source comparison) using Tortoise Diff.


1: using ApprovalTests.Reporters;
2: using NUnit.Framework;
3:  
4: namespace ApprovalTests.Tests.Html
5: {
6: [TestFixture]
7: [UseReporter(typeof(DiffReporter), typeof(FileLauncherReporter))]
8: public class HtmlTest
9: {
10: [Test]
11: public static void TestHtml()
12: {
13: Approvals.ApproveHtml("<html><body><div style='font-family:Broadway;font-size:18'> Web Page from ApprovalTests</div></body></html>");
14: }
15: }
16: }


I have found that using the right Reporter or Reporters at the right time in the testing cycle has made me more productive. Let me know how it works for you.
Happy testing!

12 comments:

woaksie said...
This comment has been removed by the author.
Spoc-Web said...

It would be nice to find a short description of each reporter here, so we know, which one to use best for a certain purpose.

Bonads Kuticy said...

Now you can see today the reason why all the movie star can simply have enough money for your partner chic clothes. Even though most people could not, all of us might test, mainly because there is not much reduce. A real see rates over low cost, and that is exactly for the novice type. A watch wonderfully copy all assortment out there, and also meant for a couple in number of $. This looks after bring ahead a hard traditions involving okay watchmaking. The whole works were only available in 1884, when trademark president, chose to totally dedicate by his own to highly arduous discipline to build perfection instruments. More so, the person required her interest in into the rank well of being a skill. Suitable from the beginning, that sit back and watch offers played a crucial purpose in the having with the hand chronograph. Thanks to his or her faithfulness involving producing basically high-performance wax replica watches, well-performing industry looks after fake watches, a manufacturer quickly obtained attention and praise as a result of stressful derricks, prefer aviation, sporting, development and even trade. This different watches happen to be a budget friendly approach to appreciate the many good stuff that include this specific brand: level of quality, great satisfaction and also seems to be which will established these in addition to the rivals. Let us carry glimpse back again inside the inventions the fact that constructed all of these time period technology precisely what they are just currently - needs pillars regarding fashionable watchmaking. These days, present see why a lot of these wrist watches really are for that reason highly-priced, obviously currently being past the particular access on most men and women. And yet these days, with the wide accessibility to superior quality looks after http://www.attrinity.com, just about every sit back and watch significant other will be able to have a modest joint of heritage. Having timepieces, your excellent story for high-quality watchmaking will be able to become unraveled while in the view of the observe lovers.

Jayna firman said...

baju import jual baju grosir baju fashion online baju murah grosir baju dress pusat frosir baju supplier baju baju online toko baju wanita baju korea grosir baju baju wanita murah baju import jual baju grosir grosir baju baju grosir korea reseller baju korea grosir busana baju fashion

Nettie yaka said...

Tas Cantik Rumah Dijual Bsd Bu Rumah Dijual SD City Tas Grosir Murah Produk Pemutih Wajah Batam Tas Branded Tas Rumah Dijual Foresta Kosmetik Buat Wajah Krim Pemutih Badan Rumah Di Jual Di Al Tas Branded Import Tas Tas Murah Jual Rumah Murah Bsd Tas Tas Batam Jual Rumah Bsd Nusa Rumah Dijual BSD Jual Tas Pemutih Badan Yg Am Tas Tas Batam

Benny carrolina said...

produk kecantikan khasiat cream alami krim pemutih prdouk wajah unggulan krim pemutih ketiak produk kecantikan kosmetik wajah aman produk kecantikan wajah krim pemutih wajah herbal pemutih kulit badan krim pemutih jual baju wanita jual baju import grosir pakaian wanita grosi baju korea tas import branded butik tas online tas branded Jual Rumah

Benny carrolina said...

Rumah Alam Sutera Rumah Dijual Alam Sutera Rumah Bintaro Rumah Dijual Bintaro Rumah BSD Rumah Dijual BSD Rumah Gading Serpong Rumah Dijual Gading Serpong Jual Apartemen jual apartemen aceh langsa jual apartemen bali badung jual apartemen bali denpasar jual apartemen kota cilegon jual apartemen banten serang jual apartemen tangerang jual apartemen alam sutera jual apartemen bsd tangerang jual rumah jual rumah banten jual rumah kota cilegon jual rumah serang jual rumah tangerang

Rudolf suwiko said...

Tas Cantik Rumah Dijual Bsd Bu Rumah Dijual SD City Tas Grosir Murah Produk Pemutih Wajah Batam Tas Branded Tas Rumah Dijual Foresta Kosmetik Buat Wajah Krim Pemutih Badan Rumah Di Jual Di Al Tas Branded Import Tas Tas Murah Jual Rumah Murah Bsd Tas Tas Batam Jual Rumah Bsd Nusa Rumah Dijual BSD Jual Tas Pemutih Badan Yg Am Tas Tas Batam

for IT the said...

Great Article
Online Java Training | Java EE course | Java Course in Chennai | Java Training in Chennai | Java Training Institutes in Chennai | J2EE Training in Chennai | java j2ee training institutes in chennai

Clement vanesha said...

Cara Membuat Genteng Kanopi Rumah Reseller Tas Tas Fashion Rumah Di Alam Suter Harga Konblok Dijual Rumah Di Bsd Harga Pipa Besi 2 Inch Jual Rumah Bsd Tas Batam Grosir Jasa Arsitek Jogja Rumah Dijual Bsd Nusa Loka Pasir Putih Jual Rumah Kencana Jual Krim Pemutih Perumahan Gading Serpong Cream Pemutih Selan Grosir Baju Murah Supplier Tas Murah Tas Kantor

Sunny ipank said...

Kursus Online http://jasatraining.xyz Jasa Jual Beli biro jasa perijinan jasa bangun rumah jual rumah tangerang gading serpong grosi baju korea Jasa Akuntansi jasa kontraktor Promosi Bisnis Online http://birojasa.xyz jasa desain furniture Jasa Desain Interior jual apartemen bsd tangerang Jasa Pemasaran Online Konsultan Pajak Jasa Catering Jasa Video Shooting Catering Jakarta Rental Mobil Jakarta Rumah Dijual Alam Sutera biro jasa perijinan jasa bangun rumah jual rumah tangerang gading serpong grosi baju korea Jasa Akuntansi jasa kontraktor Promosi Bisnis Online http://birojasa.xyz jasa desain furniture Jasa Desain Interior

Benny carrolina said...

Denah Rumah Tinggal Pagar Balkon Tas Batam Murah Batu Garut Merah Design Interior Minimalis Tas Kw Branded Rumah Murah Di Gadi Model Kanopi Rumah Dijual Di Ala Jual Rumah Bsd Gree Cream Pemutih Muka Toko Wanita Online Harga Gula Pasir 1 Kg Harga Pagar Besi Minimalis Jual Rumah Bsd City Pusat Baju Murah Grosir Murah Cream Pemutih Yang Beton Ringan Kanopi Rumah test