简体   繁体   中英

Run a single unit test from a fixture of many in MbUnit

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();
    }
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM