Gallio v3.1 is a major upgrade to the platform. This release includes many new features, better performance, and improved robustness.
Highlights:
- Video capture and embedding in test reports.
- RSpec!
- Support for .Net Framework 4.0.
- Support for Visual Studio 2010 Beta 1.
- Control Panel application.
- Brand new plug-in model with improved startup performance.
- Major internal redesign.
- More MbUnit goodness.
Download here: http://www.gallio.org/Downloads.aspx
Documentation here: http://www.gallio.org/Docs.aspx
Earlier release notes: v3.0.6, v3.0.6 update 1, v3.0.6 update 2, all versions
Installation Notes
We recommend completely uninstalling any previous installation of Gallio before installing the new one. Be sure to shut down Visual Studio while uninstalling because some files may still be in use.
We strongly recommend installing KB963676 before installing Gallio. This patch fixes some Visual Studio crashes that may occur while editing ASP.Net pages.
New and Noteworthy
Video Capture and Embedding
Gallio now includes support for capturing video screen recordings and embedding them in test reports.
Why?
Imagine you were writing integration tests for a Web or GUI application through the UI using a library like WatiN or White. When the test fails, it is very handy to have a record of just what happened.
Magic
In the next couple of sections I'm going to show how you can capture and embed screen recordings like the following into Gallio test reports.
Screen Capture and Embedding
This is all it takes to capture and embed a screenshot in the test report.
Or if we just want to capture a screenshot when a test fails or is inconclusive, here's how we can do it. We can also scale the image by 25% to keep the report small while still preserving enough detail to read.
As you can see the Capture class has some interesting methods.
Creating and Embedding Videos
A video is just an encoded sequence of frames. So we can build up a screen recording by taking screenshots at intervals and adding them to an instance of the Video class such as a FlashScreenVideo.
Notice that you can create videos of anything you like. You are not limited to screen recordings.
Screen Recording and Embedding
Gallio offers a few shortcuts to simplify screen recording in particular.
The ScreenRecorder class captures screenshots in a background thread and assembles them into a Video that can later be embedded.
The Capture class also provides a method for automatically embedding a screen recording based on the outcome of the test. It starts a screen recorder in the background and when the test finishes decides whether to embed the video or discard it.
This is a very powerful one-liner...
Here we set things up to capture a screen recording at 5 frames per second and 25% zoom factor and cause it to be automatically embedded if the test fails or is inconclusive.
Overlays
Raw screen recordings are very useful but we can enrich them with additional information. For example, while playing back the recording, it can be useful to see a transcript of what the system was doing when it captured the frame.
Gallio supports applying any number of Overlays to any screen recording. An overlay is a basically an object that paints itself onto an image.
We're going to use a CaptionOverlay to add a caption to the video as we record it. We can change the caption between frames to display a variety of information.
That's a lot of work so the Capture class provides a few convenience methods for setting a caption overlay for its screen captures and screen recordings.
Magic Recipe for WatiN
Here's the whole recipe for hooking up automatic screen recordings with WatiN 2.0.
public abstract class WatiNFixture
{
protected Browser Browser { get; private set; }[SetUp]
public void SetUp()
{
Logger.LogWriter = new GallioLogger();Capture.SetCaptionAlignment(HorizontalAlignment.Center, VerticalAlignment.Bottom);
Capture.SetCaptionFontSize(32);
Capture.AutoEmbedRecording(TriggerEvent.TestFailedOrInconclusive,
"Screen Recording",
new CaptureParameters() { Zoom = 0.25 }, 5 /*frames per second*/);IE ie = new IE();
ie.ShowWindow(NativeMethods.WindowShowStyle.ShowMaximized);
Browser = ie;
}[TearDown]
public void TearDown()
{
Capture.SetCaption("");if (Browser != null)
{
Browser.Close();
Browser = null;
}
}private sealed class GallioLogger : ILogWriter
{
public void LogAction(string message)
{
Capture.SetCaption(message);
TestLog.WriteLine(message);
}public void LogInfo(string message)
{
TestLog.WriteLine(message);
}public void LogDebug(string message)
{
// Ignore these messages.
}
}
}public class SampleTest : WatiNFixture
{
[Test]
public void GoogleSearchAndVisitMaps()
{
Browser.GoTo("http://www.google.com");Browser.TextField(Find.ByName("q")).TypeText("Ottawa");
Browser.Button(Find.ByName("btnG")).Click();Browser.Link(Find.ByText("Ottawa, ON Canada")).Click();
Browser.Link(Find.ByText("Parliament Hill")).Click();
Browser.Link(Find.ByText("Full article")).Click();
Assert.Fail("Just for show.");
}
}
RSpec and IronRuby
Now for something completely different: RSpec integration.
Big News
The big news here is that Gallio now supports running tests that are defined in files instead of just .Net test assemblies. This means you can pretty easily create custom test framework adapters for any kind of file that you know how to process and then run those tests using Icarus and other tools.
Yes, that means you can implement 5 methods of ITestDriver (or one of the helper subclasses Gallio provides) and have a custom test framework of your own using whatever kinds test files you like be they spreadsheets, XML files, native executables, or programming language text.
RSpec in Action
Let's suppose we have implemented a "Bowling" class that computes the score of a bowling game. (This example is borrowed from the RSpec site.)
class Bowling
def hit(pins)
enddef score
0
end
end
Obviously this implementation will not get us very far. So we write some specs to guide us along.
require 'bowling'
describe Bowling do
it "should score 0 for gutter game" do
bowling = Bowling.new20.times { bowling.hit(0) }
bowling.score.should == 0
endit "should score 300 for perfect game" do
bowling = Bowling.new12.times { bowling.hit(10) }
bowling.score.should == 300
endit "should score 20 for single pin hit each ball" do
pending("Scoring to be implemented.")
end
end
RSpec + Icarus
Now we just add the bowling_spec.rb file to Icarus, and run...
RSpec + Icarus + AutoRun = Bliss
When programming in a BDD way you will probably find it useful to enable the Icarus auto-run feature. Then whenever you edit the spec, they will be reloaded and re-executed.
It's a little slow right now but expect it to get better in future versions.
MbUnit Features
Yann Trévin has been busy cooking up new features for MbUnit v3.1.
Retry.Until
The Retry class makes it easy to implement polling loops in tests. Polling loops are useful when the test must wait for an asynchronous operation to complete but does not know how long it might take.
More information about Retry.Until.
Assert.Sorted and Assert.Distinct
Two new assertions for checking whether the elements in a collection are sorted or are distinct.
More information about Assert.Sorted.
More information about Assert.Distinct.
Assert.ForAll and Assert.Exists
Two new assertions for checking whether a property holds true for all elements of a collection or for at least one of them. These assertions are incredibly useful.
More information about Assert.ForAll and Assert.Exists.
Assert.Throws for Inner Exceptions
Assert.Throws now accepts an optional second type parameter to specify an inner exception type.
More information about Assert.Throws in general.
StructuralEqualityComparer
Did you ever have a data structure that you wanted to check for equality but it did not override Object.Equals? Ever grumble about having to implement this check manually?
MbUnit v3.1 includes a new feature called a structural equality comparer. The idea is to make it super easy to compare all members of a structure according to some rule. Basically you just provide a list of lambda expressions to select structure members to compare and then you optionally provide a comparison predicate. MbUnit will then compare the structure member by member using the provided selectors and predicates.
More information about StructuralEqualityComparer.
EnumData, SequentialNumbers, RandomNumbers and RandomStrings
Yann wrote a bunch more nifty data source attributes. Here they are in one big combinatorial test.
[MultipleCulture]
The [MultipleCulture] attribute runs a test repeatedly with different cultures.
[Impersonate]
The [Impersonate] attribute runs a test using different user credentials.
TestContext.AutoExecute
TestContext.AutoExecute makes it easy to register actions to perform when a test passes or fails without needing to write a [TearDown] method.
This example captures and embeds a screenshot in the test report whenever the test fails.
Control Panel
Gallio now has a control panel application where you can set all sorts of preferences.
Feel free to suggest other things for us to add to the control panel.
Gallio Runtime Settings
The Gallio runtime settings let you tweak some global parameters. Currently it lets you set custom plug-in paths in case you have installed other Gallio plug-ins elsewhere in your system.
Expect this list to grow...
Icarus Settings
All of the Icarus settings have moved to the Control Panel so you can configure them in the same place as other settings.
TestDriven.Net Settings
Now we have a place to configure settings for TestDriven.Net.
The Frameworks page lets you configure whether Gallio will be the default or preferred test runner for different frameworks. For example if you have csUnit installed and you prefer to use Gallio to run csUnit tests with TestDriven.Net then you can set Gallio's priority to "Preferred". If you set Gallio's priority to "Default" then Gallio will only be used if there is no other installed test runner available for a particular framework.
AutoCAD Settings
Mike Sandberg contributed a new preference panel for configuring the AutoCAD integration.
The AutoCAD integration still supports the "AcadAttachToExisting" and "AcadExePath" runner properties but having a GUI is certainly much nicer...
Plugin Diagnostics
Just for completeness, Gallio also displays a list of all installed plug-ins.
(Later on we will be adding a proper plug-in manager with the ability to download and install plug-ins separately.)
Visual Studio Test Tools Enhancements
Visual Studio 2010 Beta 1
Gallio v3.1 now includes support for Visual Studio 2010 Beta 1 out of the box.
Data-Driven Test Results (Fixed)
Gallio now correctly displays the results of data-driven tests like MbUnit row tests.
In the following screenshot you can clearly see both test results of a data-driven test. Previous versions of Gallio would only show one result.
AutoCAD Integration
In addition to the new preference panel, we have made a couple of minor enhancements to the AutoCAD testing experience.
Debugging AutoCAD Tests
With Gallio v3.1, you can now debug your AutoCAD tests using Icarus just like any other tests.
Previously debugging did not work because the Visual Studio debugger is unable to attach to a process that uses fibers (like AutoCAD does). So Gallio v3.1 launches AutoCAD with the debugger attached from the start and it works.
We also support zero-installation execution of AutoCAD tests. This means you can run tests on a machine with AutoCAD installed without having to separately install Gallio as long as the files have been copied to the local disk somewhere.
TeamCity Integration
Gallio v3.1 now automatically detects when it is being run by TeamCity and enables the TeamCity test runner extension. This means you do not need the following in your build scripts any more: "TeamCityExtension,Gallio.TeamCityIntegration".
There have also been some fixes to more correctly output test results from parallelizable tests.
Performance
We have invested some time improving the performance of Gallio and MbUnit v3.1 in several key areas.
Startup Time
Gallio v3.1 is much faster to start up than previous versions of Gallio.
Much of this gain comes from three important changes. First, the new plug-in model in Gallio exposes more declarative metadata up front so that we can defer loading assemblies until they are actually needed. Second, once we have identified all of the plug-ins that are installed, we cache the composite metadata for subsequent runs. Third, we generate XmlSerializers ahead of time.
On my slow laptop Icarus startup time dropped from over 20 seconds to about 2 seconds. These startup time improvements also carry over to the Visual Studio and ReSharper integration.
Memory Usage
Gallio v3.1 uses significantly less memory when running multiple test assemblies than it did in v3.0.6.
Older versions of Gallio used to keep all of the test assemblies loaded in memory for the duration of the test run. When running dozens of test assemblies together at once (say, during a continuous integration build) Gallio would end up consuming quite a lot of memory in proportion to the number of test assemblies.
Now Gallio v3.1 loads and unloads each test assembly before moving on to the next one. This change improves responsiveness and keeps memory usage in check.
Debugging and Profiling
One of the more perplexing performance problems we addressed in MbUnit v3.1 was the performance of the debugger.
In older versions of MbUnit v3 it would sometimes take half a second or more to single-step while running a test in the debugger. The problem is that the stack was just too deep. During a typical test run, the stack could be 160 frames deep!
Now MbUnit v3.1 is more carefully tuned to minimize its stack depth. We have reduced the effective stack depth by a factor of 5 so single-stepping is zippy and responsive just like it should be.
One happy side-benefit of reduced stack depth is that it significantly easier to figure out what it going on when running tests with a code profiler.
.Net 4.0 Support and x86/x64 Processor Architecture Enhancements
Gallio v3.1 includes out of the box support for .Net 4.0. We also improved our support for running tests in different processor architectures.
One key change is that Gallio runs each test assembly in its own process by default. Gallio automatically detects the required .Net runtime version and processor architecture by examining the assembly metadata. You can run tests designed for different .Net runtimes or processors architectures side-by-side if you like. All you need to do is compile your test assemblies with the right options.
It just works.
Robustness
We have worked hard to improve the robustness of Gallio v3.1 while adding new features.
UAC Privilege Elevation on Vista and Windows 7
Did you notice that the Control Panel application displayed the UAC shield icon? Here it is again:
The shield indicates that Gallio has detected that the Control Panel is running in a lower privilege environment and that certain settings that have changed require elevation. Of course when you click on the button you will receive a UAC prompt after which Gallio will carry out the required operation in an elevated context.
ReSharper Integration Bug Fixes
We have spent some time improving the robustness of the ReSharper integration. It used to throw up annoying exceptions here and there and occasionally would crash. Hopefully this is all a thing of the past.
Here's some bad code that used to cause Visual Studio to crash but not anymore:
public class A : B
{
}public class B : A
{
}
Gallio.Utility Power Tool
Gallio.Utility.exe is a new command-line application included with Gallio to perform various functions related to maintaining a Gallio installation.
These are the supported utility commands at this time:
- ClearCurrentUserPluginCache: Clears the plugin cache of the current user.
- ResetInstallationId: Resets the installation id. The plugin list will be refreshed the next time a Gallio application is started.
- Setup: Installs or uninstalls components.
- VerifyInstallation: Checks for runtime installation errors.
More Goodies
MbUnit:
- MbUnit assertions offer EqualityComparison<T> and IEqualityComparer<T> overloads.
- Parallelizable tests run with the correct number of threads and start up immediately without requiring any prior "warm-up" period as was seen in earlier versions due to some bad logic.
- Support the use of Assert.Inconclusive and Assert.Terminate within Assert.Multiple blocks.
- Contract verifiers can be "static" in which case they behave like static test factories instead of like dynamic test factories. In a "static" contract verifier, each individual verification will appear as a separate test in the test runner.
csUnit:
- Upgraded to csUnit v2.6.
NUnit:
- Upgraded to NUnit v2.5.2 but retained support for NUnit v2.4.8 also.
MSTest:
- Rewrote most of the MSTest integration to be faster and more robust.
Command-line tools:
- Gallio.Echo.exe supports wildcards.
- The NAnt, MSBuild and PowerShell tasks support specifying the Verbosity.
- Echo support a /no-progress switch to disable progress reporting.
Icarus:
- Icarus now has a "Recent Projects" menu.
- Icarus test tree is a bit faster.
- Lots of Icarus bug fixes.
- New error dialog.
- Support keyboard navigation.
- Disabled the watchdog timer during debugging runs so you can debug at leisure without worrying about the test runner killing the process prematurely.
Test Reports:
- Support embedded HTML content and Flash videos.
- Workaround issues when clicking links to attachments in IE due to the Local Machine Zone Lockdown.
- Display test kind icons in the report.
- Added a condensed text report type.
- Test output is normalized before writing it to the log. This is to catch problems like attempting to write a null character or BOM into the report.
- Test framework nodes are no longer emitted.
Debugging and Code Coverage:
- Gallio launches the debugger with the "Managed and Native" debugging engine selected so that you can debug into native code from managed code.
- NCover v1.5.8 works on x64 but only supports running tests in x86 mode.
- Using NCoverExplorer or NCover.Reporting to merge NCover coverage reports when running test assemblies in separate processes.
ReSharper:
- Lots of bugfixes.
TestDriven.Net:
- Gallio now supports zero-installation TestDriven.Net test runs with recent beta builds of TestDriven.Net. I expect Jamie will say more about this feature soon...
Pex:
- MbUnit.Pex no longer included. The Pex project has taken over the maintenance of this extension.
CruiseControl.Net:
- Added support for CruiseControl.Net v1.4.4 and more recent versions.
Documentation:
- Yann performed a massive documentation sweep to clean up formatting.
- Switched to Sandcastle instead of NDoc 2 Alpha.
Core:
- Brand new test framework extension API. Only 5 methods to implement.
- Early Transition to a message-based protocol for test framework integration.
- Massive refactoring of namespaces and interfaces.
6 comments:
Great job! I love Gallio.
Amazing job you've done. You're the best .NET open source development project, as far as I'm concerned.
Thanks a lot! We really love Gallio!
I'm a .net developer and perform some unit test, I searched for and find Gallio, mbunit, nunit usefull, all I need a tool to test using various test frameworks and I'm happy with what Gallio does. Great Job!
Gallio Team
Thanks!
Is there any way to do a "require" on the RSpec plugin? For example, if I run a command line rspec test as: "spec -rbook_selenium search_spec.rb", is there a way to get Gallio to send that require and the filename to the instantiation of rspec underneath?
Becky, unfortunately custom requires are not supported at this time.
You could probably add in a similar feature by editing the underlying Ruby source files that Gallio uses to shim in RSpec support. The basic idea would be to define a "test runner parameter" specifying a list of requires that you want to add.
The RSpec add-in is pretty straightforward. Patches welcome. :)
Post a Comment