Questions tagged [xunit2]

Related to the version 2 of XUnit

Related to the version 2 of XUnit: https://github.com/xunit/xunit/releases

64 questions
204
votes
41 answers

Why is the Visual Studio 2015/2017/2019 Test Runner not discovering my xUnit v2 tests

UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the same. I've read Why is the xUnit runner not finding my tests, which covers reasons xUnit would never be able…
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
87
votes
2 answers

How do I run specific tests using dotnet test?

I have a large test suite in a .NET Core project. I can use the Test Explorer window to select a few tests to run. I can also run the whole test suite on the command line with dotnet test. Is there a way to run only one (or a few) tests on the…
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
61
votes
4 answers

How to implement XUnit descriptive Assert message?

Context in XUnit github I found this: Add Assert.Equal(expected, actual, message) overload #350 (so a developer ask for a non existing overload see below) Quote from the answer: We are a believer in self-documenting code; that includes your…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
54
votes
5 answers

MemberData tests show up as one test instead of many

When you use [Theory] together with [InlineData] it will create a test for each item of inline data that is provided. However, if you use [MemberData] it will just show up as one test. Is there a way to make [MemberData] tests show up as multiple…
NPadrutt
  • 3,619
  • 5
  • 24
  • 60
27
votes
2 answers

Reconfigure dependencies when Integration testing ASP.NET Core Web API and EF Core

I'm following this tutorial Integration Testing with Entity Framework Core and SQL Server My code looks like this Integration Test Class public class ControllerRequestsShould : IDisposable { private readonly TestServer _server; private…
23
votes
1 answer

"dotnet test": how to run xunit tests projects in parallel?

I am runnning all tests projects from solution level with a single command: dotnet test how can I make all tests projects(assemblies) run in parallel? In Visual Studio there is a simple button "Run tests in parallel" which works perfectly but I need…
Deivydas Voroneckis
  • 1,973
  • 3
  • 19
  • 40
22
votes
2 answers

xUnit Assert.All() async

I have this example test using xUnit: [Fact] public void SomeTest() { Assert.All(itemList, async item=> { var i = await Something(item); Assert.Equal(item,i); …
J2ghz
  • 632
  • 1
  • 7
  • 20
20
votes
9 answers

Collection fixture won't inject

I'm using xUnit 2.0 collection fixtures to share a common database setup/teardown between a number of different test classes. The fixture also provides some helper properties, so I'm injecting it into each test class. I recreated the example in the…
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
15
votes
2 answers

Unable to get ConfigurationBuilder to read from appsettings.json in xunit class library in ASP.NET Core 1.0 RC2

I am trying to do the following in an XUnit project to get the connectionstring to the database my tests should be using: public class TestFixture : IDisposable { public IConfigurationRoot Configuration { get; set; } public MyFixture() …
Blake Rivell
  • 13,105
  • 31
  • 115
  • 231
14
votes
5 answers

xUnit.net v2 not discovering .NET Core Tests in Visual Studio 2015

I am really frustrated with this issue. I have already tried changing the version numbers but no tests are showing in the test explorer. In the test output window I can see this output Starting Microsoft.Framework.TestHost…
Sul Aga
  • 6,142
  • 5
  • 25
  • 37
7
votes
4 answers

Logging with Specflow and xUnit 2 (ITestOutputHelper)

Unfortunately I have a Specflow test passing locally, but it fails on the VSO Build vNext server, and I really need to see verbose information during the test run so I can figure out what is going on. But I'm struggling to try to inject…
softbear
  • 485
  • 6
  • 16
7
votes
2 answers

Customize Test Name in Xunit2

When I run my tests today with xUnit v2, I typically use a naming convention like: [Fact(DisplayName= "Method Will Do Something")] public void Method_Will_Do_Something() { } What extensibility point can I plug into that will allow me set my test…
cecilphillip
  • 11,446
  • 4
  • 36
  • 40
5
votes
2 answers

Is ConstructorInfo.GetParameters Thread-Safe?

This is a very strange problem that I have spent the day trying to track down. I am not sure if this is a bug, but it would be great to get some perspective and thoughts on why this is happening. I am using xUnit (2.0) to run my unit tests. The…
Mike-E
  • 2,477
  • 3
  • 22
  • 34
5
votes
1 answer

Unable to load application or execute command 'Microsoft.Dnx.TestHost'. Available commands: test

Trying to test an ASPNET 5 application in VS2015. { "version": "1.0.0-*", "description": "HoldingTank Class Library", "dependencies": { "EntityFramework.InMemory": "7.0.0-rc1-final", "FluentAssertions": "4.1.1", "GenFu": "1.0.4", …
4
votes
1 answer

getting an error The following constructor parameters did not have matching fixture data: PostgreSqlResource resource

I am using xunit to do integration testing, and below is my test class. public class CodesAndGuidelinesTest : IClassFixture { public readonly SchemaCache schemaCache; public CodesAndGuidelinesTest(PostgreSqlResource resource) …
Glory Raj
  • 17,397
  • 27
  • 100
  • 203
1
2 3 4 5