NSpec icon indicating copy to clipboard operation
NSpec copied to clipboard

Idea (NUnit, XUnit migration)

Open amirrajan opened this issue 8 years ago • 2 comments

Would be cool if you could do:

//somwhere inside of a custom Program.cs that references both NUnit and NSpec

var builder = nspecThingy.TestFinder(someAssembly, (methodInfo) => 
{
    if (nspecThingy.ContainsAttribute<Setup>(methodInfo))
    {
	return nspecThingy.Before();
    }
    
    if (nspecThingy.ContainsAttribute<TestMethod>(methodInfo))
    {
	return nspecThingy.Context("NUnit Method: " + methodInfo.Name);
    }
    
    if (nspecThingy.ContainsAttribute<TearDown>(methodInfo))
    {
	return nspecThingy.After();
    }
    
    return nspecThingy.Skip();
});

specRunner.run(builder, builder2, builder3);

amirrajan avatar Jul 27 '17 00:07 amirrajan

@BrainCrumbz, thoughts? ^

amirrajan avatar Aug 25 '17 00:08 amirrajan

That looks quite like some kind of adapter from NUnit to NSpec 😺 . Might be interesting.

Going from the top of my head, are those the only test attributes we should look for within NUnit? Looking at doc page, there might some more to look at: TestFixture, Test. And when pushing forward with adaptation: OneTimeSetUp, OneTimeTearDown, SetUpFixture, TearDownFixture. Then theories as well, to somehow map them to parameterized tests.

BrainCrumbz avatar Sep 10 '17 19:09 BrainCrumbz