DEV Community

Russ Hammett
Russ Hammett

Posted on • Originally published at kritner.blogspot.com on

1 1

"non string" category NUnit tests

Didn't feel very "clean" about [Category("MyCategory")] peppered throughout the code base. This makes me feel a little better, though I wish I could easily apply the category attribute to an entire assembly.

    // Haven't figured out how to apply to assembly correctly, but added it as a flag in my base anyway
    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
    public class BaseCategoryAttribute : CategoryAttribute { }

    public class FastIntegrationTestAttribute : BaseCategoryAttribute { }
    public class LongRunningIntegrationTestAttribute : BaseCategoryAttribute { }
    public class UnitTestAttribute : BaseCategoryAttribute { }
    public class CoreTestAttribute : BaseCategoryAttribute { }

    [TestFixture, UnitTest]
    public class SomeClassTests
    {
        // This test has categories UnitTest, CoreTest
        [Test, CoreTest]
        public void ShouldDoSomething()
        {
        }
    }

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
kritner profile image
Russ Hammett

Pretty paste seemingly did not translate super well to dev.to :joy:

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️