Monday, October 4, 2010

Fixture initialization in FakeItEasy

I added a new feature to FakeItEasy that makes it – you guessed it – easy to initialize test fixtures with fakes.

Instead of calling A.Fake<WhateverTypeYourFakingHere>() once for every fake you have in your test fixture you can simply tag the variables or properties you want to be fakes with the “FakeAttribute” and then call the method “Fake.InitializeFixture(this)” in your fixture setup:

[TestFixture]
public class InitializeFixtureIntegrationTests
{
    [Fake] IFormatProvider formatProvider;
    [Fake] IFormattable formattable;

    [SetUp]
    public void SetUp()
    {
        Fake.InitializeFixture(this);
    }

        
    [Test]
    public void Should...

1 comment:

  1. That's a really cool feature!

    ReplyDelete