Different data-driven fixture in C#

49 views
Skip to first unread message

Viktor Haas

unread,
Oct 7, 2011, 8:16:17 AM10/7/11
to galli...@googlegroups.com
Hi,

I'm using MbUnit 3.3 and try to create tests with different values in [FixtureSetUp].

I found Jeff's blog with an example for that, but it's not working.
http://blog.bits-in-motion.com/2008/05/mbunit-testfixture-attribute-is-now.html
Please check example 4: A different data-driven fixture in C# using a constructor.

I noticed function Fixture never executed and the example didn't work at all.
I created a small example based on that.

public class Example
{
    private String productName;
    private String product;

    [SetUp]
    [Row("Fluffy Puff Marshmallows")]
    [Row("Cheat Command O's")]
    public void BuyProduct(String productName)
    {
        TestLog.WriteLine("Name: {0}", productName);
        product = productName;
    }

    [TearDown]
    public void ReturnProduct()
    {
        product = "";
    }

    [Test]
    public void ShouldComeInAShinyBox()
    {
        TestLog.WriteLine("Test: {0}", product);
    }
}

I got the following error message:
Set Up
System.ArgumentException: The method has 1 parameters but the bindings only provide values for 0 of them.
at Gallio.Framework.Data.MethodInvocationSpec.ResolveArguments() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Framework\Data\MethodInvocationSpec.cs:line 180

I notice Row or Column worked with only [Test] and no effect with [FixtureSetUp] or [SetUp].

Could you help me how can I create fixture with different values in [SetUp] part?

Thanks in advance.

Viktor

Viktor

unread,
Oct 10, 2011, 4:39:03 AM10/10/11
to gallio-user

Brian Kitchener

unread,
Oct 19, 2011, 10:15:38 AM10/19/11
to galli...@googlegroups.com
You cannot use DDT Attributes on the Setup Fixture.  


--
You received this message because you are subscribed to the Google Groups "gallio-user" group.
To post to this group, send email to galli...@googlegroups.com.
To unsubscribe from this group, send email to gallio-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gallio-user?hl=en.


Viktor

unread,
Oct 20, 2011, 3:48:25 AM10/20/11
to gallio-user
Is there no way at all to run [SetUp] part with different parameter?
So I have to duplicate the whole Fixture, which is not a nice
solution :(

On Oct 19, 4:15 pm, Brian Kitchener <kitchener.br...@gmail.com> wrote:
> You cannot use DDT Attributes on the Setup Fixture.
>
>
>
>
>
>
>
> On Mon, Oct 10, 2011 at 2:39 AM, Viktor <viktor.h...@gmail.com> wrote:
> > Hi,
>
> > I'm using MbUnit 3.3 and try to create tests with different values in
> > [FixtureSetUp].
>
> > I found Jeff's blog with an example for that, but it's not working.
>
> >http://blog.bits-in-motion.com/2008/05/mbunit-testfixture-attribute-i...

Graham Hay

unread,
Oct 20, 2011, 5:22:47 AM10/20/11
to galli...@googlegroups.com
How about:

   private void BuyProduct(String productName)

   {
       TestLog.WriteLine("Name: {0}", productName);
       product = productName;
   }

   [TearDown]
   public void ReturnProduct()
   {
       product = "";
   }

   [Row("Fluffy Puff Marshmallows")]
   [Row("Cheat Command O's")]
   public void ShouldComeInAShinyBox(String productName)
   {
       BuyProduct(productName);

Brian Kitchener

unread,
Oct 20, 2011, 10:08:39 AM10/20/11
to galli...@googlegroups.com
No, you can bind to a variable, constructor, test or function, just not Setup.
Reply all
Reply to author
Forward
0 new messages