Sunday, September 23, 2012

SmokeTest for .NET Reflector

.net SmokeTest is a Windows application that presents an interactive interface into any .net Assembly allowing you to smoke-test an API via reflection. You can call any member without ever writing a single line code. An indispensible tool for anyone involved in developing, testing and managing software products for Windows.

Now you can leverage the full power of SmokeTest from inside .NET Reflector. Don't just view the code, smoke-test it. The SmokeTest Add-In allows you to interactively:
  • create an instance of a Class.
  • call any Method
  • get and set any Property
  • read and write any Field
  • create, edit and store object instances to pass as arguments.
  • drill-down and smoke-test the returned result.
For a detailed tutorial on how to use .net SmokeTest see my previous Blog posts.


Download and install the latest version of .net SmokeTest if you haven't already done so.

From Reflector select the Add-Ins menu item and select the "Add" button then navigate to the directory where you installed .net SmokeTest and choose the SmokeTest.Reflector.AddIn.dll file. This should load the SmokeTest Add-In into your Reflector installation.

Using the SmokeTest Add-In

Now when you navigate to a smoke-testable Type in Reflector's Assembly tree (try System.DateTime in mscorlib) you will see a SmokeTest panel appear as shown here.

For a managed type to be smoke-testable it must be a class or struct (ValueType). Generic classes are currently not supported. Interfaces are not smoke-testable for obvious reasons. Also, unlike Reflector, SmokeTest must instantiate the type under test to invoke its member functions and therefore requires all supporting Assemblies and resources to be available to the Assembly under test. This usually means in the same folder as the Assembly under test.

The Basics

So just for fun let's smoke-test the built-in DateTime class. The same procedures apply to any class in the .net hierarchy including of course your own. Navigate to the System.DateTime class under the mscorlib Assembly. The SmokeTest panel should appear when you select the DateTime type as shown above.

Note that the main smoketest panel displays only the static members and constructors of the DateTime class. Of course, until you actually create an instance of a type all you can invoke are the constructors and static members.

Just out of interest click on the Methods, Properties and Fields tabs to see what other static members are available for this class. Note that Properties and Fields will always "get" the current value automatically when you select them and display the result in the preview panel at the bottom. Constructors and Methods require that you invoke the function explicitly.

Now, under the Properties tab select the "Now" property. The current local time will be displayed in the ToString preview tab as a result of invoking the property.

Notice also the "drill-down" button at the bottom right lights-up with the name of the type returned from calling the property, a DateTime in this case. The drill-down button always links to the last result object whether from a Constructor, Method, Property or Field invocation. Clicking the drill-down button will open another SmokeTest window where you can smoke-test all the members of the object instance (not just the static members).

And that's all there is to it. Now try it out with other classes and methods from your own Assemblies or just browse the Microsoft libraries.

See the SmokeTest help page for more information about using the SmokeTest Control.

Sunday, September 16, 2012

Version Released

Summary of changes in this release:

  • Support for Value (struct) types. 
  • Smoketest functionality included in a separate SmokeTestControl.dll.
  • Includes all x86 and x64 versions in the deliverables.
  • Reflector Add-In modified to reference new SmokeTestControl.dll instead of SmokeTest.exe
  • Minor UI improvements to auto-size the argument controls.

See the web page for more details.