How can XUnit be configured to show just the method name in the Visual Studio 2015 Test Explorer?

You can also add it with json. In the root directory of your test project add a file called “xunit.runner.json”. Right-click the file, properties. Select “Copy if newer” for copy to Output directory. Then in the file enter this json: { “methodDisplay”: “method” } Note that you may1 require to restart the IDE in order … Read more

How to set the test case sequence in xUnit

In xUnit 2.* this can be achieved using the TestCaseOrderer attribute to designate an ordering strategy, which can be used to reference an attribute that is annotated on each test to denote an order. For example: Ordering Strategy [assembly: CollectionBehavior(DisableTestParallelization = true)] public class PriorityOrderer : ITestCaseOrderer { public IEnumerable<TTestCase> OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases) where TTestCase : … Read more

Should GetEnvironmentVariable work in xUnit tests?

The GetEnvironmentVariable works fine in xUnit tests. The problem is to properly set a variable. If you set the variable at Properties -> Debug page, then the variable is written to Properties\launchSettings.json and Visual Studio makes all work to launch an application with the selected profile. As you could see, launchSettings.json even isn’t copied to … Read more

Pass array of string to xunit test method

Use params before the method’s string[] argument, and then you won’t need to initialize a string[] in InlineData attribute, rather you could use a variable number of string literals, for which the compiler doesn’t complain one bit: [Theory] [InlineData(“2000-01-02”, “2000-02-01”)] public void TestSynchronizeMissionStaffing_PeriodNoMatch(params string[] dateStrings)

Await Tasks in Test Setup Code in xUnit.net?

xUnit has an IAsyncLifetime interface for async setup/teardown. The methods you need to implement are Task InitializeAsync() and Task DisposeAsync(). InitializeAsync is called immediately after the class has been created, before it is used. DisposeAsync is called just before IDisposable.Dispose if the class also implements IDisposable. e.g. public class MyTestFixture : IAsyncLifetime { private string … Read more