XUnit some important test attribute and filters



Setting unit test priority using Trait Attribute.


If you ever needed your unit test to run first before other being run, then you can change the order of execution using [Trait] as shown in diagram below. The higher the value, the higher the priority.

I tried this, doesn't seems to work.

[Trait("Priority", "1")] // Run last

[Trait("Priority", "5")] // Definitely run this first


Common filter used are :-

DisplayName=MyUnitNamespace.UnitClass.UnitTest1 - Match by exact test name with equal operator

DisplayName~UnitTest - Matches any unit test that contains the text 'UnitTest' - with ~ operator

DisplayName!=IntegrationTest - Run all the test except those with 'IntegrationTest'  != operator





Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm