Build/Test Issues

Bug? Test category isn't picked up when in Attribute but MSTest understands it

Started by PaulMendoza on 6,362 views

I have NCrunch setup to only run unit tests that are marked with a test category of "Unit". I don't like having strings in my code so I made test attribute that exposes the category but NCrunch doesn't pick it up like all the other tools do.

I can write a TestCategory like this and it works.

[TestCategory("Unit")]

But if I use my custom attribute [UnitTest] it doesn't get run by NCrunch but tools like MSTest understand it.

public class UnitTestAttribute : TestCategoryBaseAttribute
{
public UnitTestAttribute()
{ }
public override IList<string> TestCategories
{
get { return new List<string> { "Unit" }; }
}
}

Please make this work.

Thanks,
Paul Mendoza
Hi Paul -

Thanks for posting!

As NCrunch uses metadata to identify categories for tests (instead of dynamic invoke), this approach to defining custom attributes currently isn't supported. I'll ensure its in the backlog for a future release.


Cheers,

Remco
For anyone interested, support for derived MSTest category attributes has been introduced with the newly released version of NCrunch (v1.45), although this will only work if you set the 'Framework utilisation type for MSTest' solution-level configuration setting to 'DynamicAnalysis'.

Post a reply

Log in to reply.