views:

264

answers:

1

Is there anyway to add an attribute to a [Test] method in a [TestFixture] so that only that method runs? This would be similar to the way the [CurrentFixture] attribute can be used to only run a single fixture. I ask as sometimes when I test the model I want to profile the sql being executed and I only want to focus on a single test. Currently I have to comment out all the other tests in the fixture.

Updated:

The code I'm using to initiate the test follows, I'm really looking for a solution I can weave into this code.

public static void Run(bool currentFixturesOnly) {
    using(AutoRunner auto = new AutoRunner()) {

        if(currentFixturesOnly) { // for processing [CurrentFixture]s only
            auto.Domain.Filter = FixtureFilters.Current;
        }

        auto.Verbose = true;
        auto.Run();
        auto.ReportToHtml();
    }
}
+2  A: 

If you use a test runner like TestDriven.Net, ReSharper or Icarus then you can select the specific test to run and just run that. If you're using the command-line tools, consider using a filter.

eg.

Gallio.Echo MyTestAssembly.dll /f:Name:TheNameOfTheParticularIWantToRun

Jeff Brown
TestDriven.Net looks like it might help, but I'm really looking for a solution I can code without any additional software. I've also updated my post to show how I am initiating the tests, which kind of rules out the command line.
Brehtt