Category "xunit"

How to use multiple Program classes in xUnit test project with WebApplicationFactory

I want to use WebApplicationFactory to create hosts for my tests, but I want to create 2 Web Application Factories for two projects I refereed in single XUnit t

EF Core xunit assert whether .Include was called

I've got extension methods in .net core that effectively dynamically evaluate stuff, and will call .Include() on an IQueryable<T>. I'd like to build unit

.net Core 3.0, DirectoryNotFoundException with Xunit Integration test

I have a new issue working on migrating my Xunit integration test on .net core 3.0. I moved the project in a subfolder and now I have a DirectoryNotFoundExcepti

How do I mock AddAsync?

I'm writing unit test. For testing the method below, public async Task<Guid> CreateWebJobStatus(string blobId, Guid loggedInUserId, string loggedInUserE

Could not load type Castle.Proxies.IReadinessProxy when running xUnit integration tests in parallel with Autofac

I am having an issue that I've been many days unable to resolve. I use xUnit with a given-then-when abstraction to make tests more readable. I am using a wrappe

TeamCity doesn't pick up result of xUnit tests when testing .NET Core project

I have a small .NET Core project, where the complete build/test/deploy process is handled in a Cake script. I have a powershell script that runs the cake scrip

Populate IConfiguration for unit tests

.NET Core configuration allows so many options to add values (environment variables, json files, command line args). I just can't figure out and find an answer

xunit test for IFormFile field in Asp.net Core

I have an Asp.net Core method with below definition. [HttpPost] public IActionResult Upload(IFormFile file) { if (file == null || file.Length == 0)

How does XUnit RetryFact attribute works?

I have Selenium tests which are run by XUnit. I write tests on c#. Some of the tests are not stable (especially those which uses mouse actions). I found the Ret

Is it possible to use Dependency Injection with xUnit?

I have a test class with a constructor that needs an IService. public class ConsumerTests { private readonly IService _service; public ConsumerTests(IS

How to test database methods and get code coverage xUnit ASP.NET

I initially used the Moq library for testing, since I don't actually want to mess the data in my database. However, I quickly realized instead of running the co

Extract Xunit test class name from ITestOutputHelper object (C# )

Can I use the ITestoutputHelper injected object to get the calling class name?

how to debug with xUnit?

I'm learning xUnit and so far, have found it to be a most useful tool. It's making me rethink some of my coding tactics to TDD instead. However, I've come acro

Unable to get EF Core logs during unit tests when using EF Core In Memory provider

I have a .net core 2.2 applications which is using a SQL database. I have written some unit tests using EF Core In Memory provider to test my data access code.

How to run XUnit test using data from a CSV file

Is there a way to run a data driven XUnit test using a CSV file as the data source? I've tried Cavity.Data.XUnit, but it's no longer compatible with the newest

Moq verifies in debug and fails sometimes in run

I've developed a wpf-mvvm application that uses wmi to document what is built into a given Computer into a json file. I've used the mvvm model to develop the ap

.Net core library: How to test private methods using xUnit

The latest xunit framework does not allow test runners in library code when compiled with .Net Core framework (this is allowed for normal Visual Studio code). T

.Net core library: How to test private methods using xUnit

The latest xunit framework does not allow test runners in library code when compiled with .Net Core framework (this is allowed for normal Visual Studio code). T

Pass complex parameters to [Theory]

Xunit has a nice feature: you can create one test with a Theory attribute and put data in InlineData attributes, and xUnit will generate many tests, and test th

xUnit shared context by private static fields

What disadvantages have an approach of sharing context by creating private static fields? If I don't need to call Dispose? public class MyTests3 : IDisposable {