XUnit and data driven testing.

I have been using XUnit and the more I use it the more I like it. I used to use NUnit (infrequently and hence I don’t know if the following features are also supported) but then I noticed a movement towards using XUnit. What really made me decide to learn more about the latter came about while going through the Outside in TDD course. In the latter, the author showed how easy it was to set up and tear down a database simply by implementing events that take place before a unit test is run. From that moment, I was hooked.

Today, while working on parametised tests, I came across the following issue:

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

and this is caused by the fact that I tried to pass a resource file in as a parameter to the attribute as follows:

[InlineData("a", "b", "c", Resources.someResource)]

I was really struggling to get round this until I found this post. I simply followed the example about PropertyData and that solved my problem.

Tagged with: ,
Posted in .NET, ATDD, XUnit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3 other followers

March 2013
« Oct   Apr »
%d bloggers like this: