Build/Test Issues

XUnit 1.9.2 tests not found when a custom TraitAttribute used

Started by piotrczarnas on 4,298 views

Hi,

I have XUnit 1.9.2 tests with a custom TraitAttribute. Tests are found when the test class is not attributed with a custom trait attribute.
The trait attribute is:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class CustomTestCategoryAttribute : Xunit.TraitAttribute
{
internal CustomTestCategoryAttribute(string category)
: base("Category", category)
{
}
}

And a usage:
[CustomTestCategory("cat")]
public class MyTest
{

Best Regards,
Piotr
Hi Piotr,

Unfortunately, the mechanics involved make custom trait attributes impossible to implement when using static analysis.

For this to work, you'll need to set the 'Framework utilisation type for Gallio' solution-level NCrunch configuration setting to 'DynamicAnalysis'. Note that DynamicAnalysis is significantly slower than StaticAnalysis when using Xunit v1. I recommend finding an alternative design if possible.

Post a reply

Log in to reply.