MbUnit v3.3 has been now released for a while and I realize that I have completely forgotten to write about the new nifty features added by our fellow contributor Aleksandr Jones. Aleks had added a couple of very powerful attributes for writing data-driven tests. He had even written some useful documentation in the Gallio wiki. Those attributes provide a seamless way to bind automatically your external data sources (CSV or XML data files) to the test parameters.Basically you can declare your test parameters as "dynamic" variables and let MbUnit to bind automagically the parameters behind the scene. Of course it also means that the feature is only available for test projects targeting the .NET 4 framework.Let's consider the following simple comma-separated example data file:
Let's now write a test method which loads the file and gets data from it. We could have used the classic
[CsvData]attribute to bind explicitly the parameters. But with the new
[FlatFileDataObject]attribute, it's far easier:
Look at how the different properties of the test parameter were bound and printed in the test log.That's just awesome! Good work Aleks!