bgeek.net

Behaviour Driven Development

Posted by Owen Evans on Thursday, October 22nd, 2009

Last night I had a lot of fun presenting at the Wellington .net User Group on Behaviour Driven Development.

Below are the slides from the talk.

Bahaviour Driven DevelopmentView more presentations from buildmaster. Sphere: Related Content

continue reading

TechEd 2009 Day 2

Posted by Owen Evans on Tuesday, September 15th, 2009

Day 2 seems a bit thinner on the ground for dev talks.

Challenging the role of Software Architect by Kevin Fancis Not so much challenging as saying we need them more, which I disagree with, had personal disagreements with the content of the talk and for the first time at TechEd I felt compelled to leave the [...]

continue reading

TechEd 2009 Day 1

Posted by Owen Evans on Monday, September 14th, 2009

Well day one is coming to a close, so before I forget I need to get my thought’s down on paper…. well virtual paper..

keynote

I really think MS need to rethink inviting politicians to TechEd, it really adds very little value for people in the audience, in the end it’s a gathering of IT professionals and [...]

continue reading

NSpecify Nunit add-in fix for InitializeFunctionality methods

Posted by Owen Evans on Friday, January 18th, 2008

Well I still exist!

Recently I’ve been moving more and more into understanding how a specification test should be written using NSpecify a really nice framework for running tests.

Also I’ve been seriously involved in getting the teams build process up and running in a much more meaningful form, as such I’ve noticed a bug in the nunit add-in for NSpecify.

It wasn’t running any of my InitializeFunctionality (Incidently i think this would be better named as ContextSetup and Functionality renamed to Context) methods.

I looked in the code and realised none of the setup’s or teardowns were getting wired up, a quick modification and there all hunky dory.

2 changes are required:

NSpecifySuiteExtension.cs should look like this

using System;
using System.Reflection;

namespace NUnit.Core.Extensions { /// <summary> /// NSpecifySuiteExtension extends test suite and creates a fixture that runs every specification implementing the NSpecify attributes. /// Because it inherits from TestSuite, rather than TestFixture, it has to construct its own fixture object and find its /// own specifications. Everything is done in the constructor for simplicity. /// </summary> internal class NSpecifySuiteExtension : TestSuite { #region C'tors

    /// &lt;summary&gt;
    /// Initializes a new instance of the &lt;see cref="NSpecifySuiteExtension"/&gt; class.
    /// &lt;/summary&gt;
    /// &lt;param name="fixtureType"&gt;Type of the fixture.&lt;/param&gt;
    public NSpecifySuiteExtension(Type fixtureType)
        : base(fixtureType)
    {
        // Create the fixture object. We could wait to do this when
        // it is needed, but we do it here for simplicity.
        Fixture = Reflect.Construct(fixtureType);
        fixtureSetUp = Reflect.GetMethodWithAttribute(fixtureType, Constants.InitializeFunctionalityAttribute, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, true);
        fixtureTearDown = Reflect.GetMethodWithAttribute(fixtureType, Constants.CleanupFunctionalityAttribute, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, true);
        // Locate our test methods and add them to the suite using
        // the Add method of TestSuite. Note that we don't do a simple
        // Tests.Add, because that wouldn't set the parent of the tests.
        foreach (MethodInfo method in fixtureType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
        {
            Attribute spec = Reflect.GetAttribute(method, Constants.SpecificationAttribute, true);
            if (spec != null)
            {
                Add(new NSpeicifyTestMethod(method));
            }
        }
    }

    #endregion
}

internal class NSpeicifyTestMethod : NUnitTestMethod
{
    public NSpeicifyTestMethod(MethodInfo method)
        : base(method)
    {
        setUpMethod = Reflect.GetMethodWithAttribute(FixtureType, Constants.SetupResourcesAttribute, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, true);
        tearDownMethod = Reflect.GetMethodWithAttribute(FixtureType, Constants.DestroyResourcesAttribute, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, true);
    }
}

}

And constants.cs just gets updated to this:
namespace NUnit.Core.Extensions
{
    /// <summary>
    /// The constants
    /// </summary>
    public class Constants
    {
        public const string FunctionalityAttribute = "NSpecify.Framework.FunctionalityAttribute";
        public const string InitializeFunctionalityAttribute = "NSpecify.Framework.InitializeFunctionalityAttribute";
        public const string CleanupFunctionalityAttribute = "NSpecify.Framework.CleanupFunctionalityAttribute";
        public const string SpecificationAttribute = "NSpecify.Framework.SpecificationAttribute";
        public const string SetupResourcesAttribute = "NSpecify.Framework.SetupResourcesAttribute";
        public const string DestroyResourcesAttribute = "NSpecify.Framework.DestroyResourcesAttribute";

    public const string SuiteBuilders = "SuiteBuilders";
}

}

I’ve got a patch file if I can get the people who have write access to the NSpecify repository to apply it (there are no mailing lists for me to send it to)

Here it is

kick it on DotNetKicks.com

Sphere: Related Content

Posted in: [|||].

kick it on DotNetKicks.com

Shout it

  • Thanks Owen, it is now committed.
    If you have any more input, just let me know!
blog comments powered by Disqus