Skip to main content
Filter by
Sorted by
Tagged with
158 votes
13 answers
168k views

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 them all. I want to have something like ...
zchpit's user avatar
  • 3,141
171 votes
46 answers
126k views

EDIT 2016-10-19: The original question was about an issue specific to VS2015 CTP6 with the XUnit test runner. It's clear from the answers that there is a much broader issue with unit test discovery ...
Fred Kleuver's user avatar
  • 8,065
28 votes
3 answers
32k views

I am trying to implement Dependency Injection in Xunit test for AppService. Ideal goal is to run the original application program Startup/configuration, and use any dependency injection that was in ...
user avatar
194 votes
10 answers
191k views

I have an assembly that I've built on Windows I want to run the xUnit tests on mono in Linux. However, I have found that while 400 of these tests can run (in order), that certain tests either hang the ...
metdos's user avatar
  • 14k
35 votes
4 answers
45k views

I am working on an ASP.Net Core MVC Web application. My Solution contains 2 projects: One for the application and A second project, dedicated to unit tests (XUnit). I have added a reference to the ...
Bob5421's user avatar
  • 9,353
51 votes
5 answers
85k views

Using EF Core (or any ORM for that matter) I want to keep track of the number of queries the ORM makes to the database during some operation in my software. I've used SQLAlchemy under Python earlier, ...
codeape's user avatar
  • 102k
87 votes
8 answers
82k views

I have a test class with a constructor that needs an IService. public class ConsumerTests { private readonly IService _service; public ConsumerTests(IService servie) { _service = ...
Rookian's user avatar
  • 20.7k
31 votes
2 answers
19k views

I am trying to test the following filter: using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Filters; namespace Hello { public class ValidationFilter : ActionFilterAttribute { ...
yokomizor's user avatar
  • 1,587
17 votes
2 answers
17k views

I have an API, and I'm trying to make some integration tests for it with XUnit. Here's my API controller constructor: public class MyController : Controller { readonly IMyRepository _myRepository;...
Steven's user avatar
  • 19k
2 votes
1 answer
482 views

I was having some trouble getting unit testing with xUnit to work in Visual Studio (2019) for my VSTO Outlook addin project. I had reviewed the following SO questions and answers: VSTO Unit Testing ...
wopr_xl's user avatar
  • 309
70 votes
9 answers
53k views

I have a xUnit test like: [Fact] public async void GetLocationsCountAsync_WhenCalled_ReturnsLocationsCount() { _locationsService.Setup(s => s.GetLocationsCountAsync("123")).ReturnsAsync(10); ...
Richard Collette's user avatar
26 votes
1 answer
19k views

In my xUnit integration test in my .NET Core 2.0 project I cannot see log messages in the terminal that also prints the test results. When the code is run in WebHost environment, the logs are printed ...
Mads's user avatar
  • 1,216
18 votes
1 answer
10k views

We have been using xUnit Framework in our project as test framework since the begining. Currently there are 2200+ unit tests in project and everything seems fine. But yesterday i decided to run unit ...
bahadir arslan's user avatar
9 votes
5 answers
12k views

I'm trying to write an ASP.NET Core 2.2 integration test, where the test setup decorates a specific service that would normally be available to the API as a dependency. The decorator would give me ...
Jeroen's user avatar
  • 64.4k
3 votes
1 answer
3k views

What I can't understand fully is exemplified in a unit test below. Basically I want to know why DbContext overrides collection values currently stored in the database even if Reload() and a new load ...
Ogglas's user avatar
  • 71.4k
2 votes
1 answer
2k views

In my Asp.net Core 2.0 application, I am trying to unit test my data service layer (.Net Standard Class Library) that uses the Microsoft.Extensions.Configuration.IConfiguration dependency injection. ...
Learning Curve's user avatar
95 votes
5 answers
48k views

I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does ...
Andrew Harmel-Law's user avatar
56 votes
3 answers
117k views

I've downloaded the latest VS2022 v17.1 Community Edition and it doesn't come with Code Coverage built-in. I'm accustomed to the Enterprise Edition and all I can find is paid options for the Community ...
Jeremy Thompson's user avatar
51 votes
10 answers
70k views

I am completely stuck on this issue. So my team has a unit test project in a services test project. The tests are discovered in the test explorer pane however when I try and run the tests I get these ...
CMR's user avatar
  • 649
42 votes
2 answers
42k views

I have a unit test project using Xunit and the method we are testing returns IActionResult. I saw some people suggest using "NegotiatedContentResult" to get the content of the IActionResult but that ...
Julie C.'s user avatar
  • 659
32 votes
3 answers
45k views

I'm trying to setup my tests using Xunit. I have a requirement to delete all images in a folder start of the tests, and then each method does some image resizing and saves a copy of it's output to the ...
Chris's user avatar
  • 8,522
25 votes
1 answer
26k views

I have a project in .NET Core and have built tests using xUnit. Now I wanted to run the test in deployment process. What I have done so far: I used this command in commandline: dotnet test [...
Meysam's user avatar
  • 583
23 votes
1 answer
37k views

We've recently started using MediatR to allow us to de-clutter controller actions as we re-factor a large customer facing portal and convert it all to C#. As part of this we are increasing our unit ...
Steve Pettifer's user avatar
20 votes
4 answers
10k views

In the Java space, JUnit is predominately used and in .NET I believe nUnit is very popular. Is a community agreed upon unit testing framework for the Ruby world? Background: I ask because I am new ...
Jon Homan's user avatar
  • 331
15 votes
6 answers
5k views

I would like to be about to use a list, array, and/or seq as a parameter to xUnit's InlineData. In C# I can do this: using Xunit; //2.1.0 namespace CsTests { public class Tests { [...
Mike Harris's user avatar

1
2 3 4 5 6