xunit Questions

3

Solved

I have the following DatabaseFixture which has worked well for all tests I have created up to this point. I use this fixture for integration tests so I can make real assertions on database schema s...
Nomo asked 23/12, 2017 at 17:26

4

My question is How to setup multiple fixtures in one test class? But the constructor of Zoo class can not handle multiple fixtures. For exemple: public class Zoo : IClassFixture<Tiger>, IC...
Brownfield asked 30/3, 2016 at 20:50

4

TLDR: To integration test a .NET Core web application, we have the WebApplicationFactory. How do I do the same thing for a worker service ? Given this worker service: // Program.cs using SampleWor...
Terzetto asked 1/10, 2023 at 18:29

2

While using xunit for testing, I'm constantly getting build errors when running the tests (CS0579 and CS0006): I have tried removing bin/obj folders and tried suppressing the generation of the a...
Ulysses asked 11/3, 2018 at 18:24

3

I have a few Web Api Controller tests. These are built with the WebApplicationFactory provided by .NET Core Tests. When I run these Controller tests one-by-one, they all pass. When I run these Con...
Weingarten asked 2/11, 2020 at 11:57

2

I have a problem with my xUnit test project. If I check tests by Right Click > Run, there is no problem, but using Run All Tests in View button (whole tests are passed both times) I got 4 warnin...
Schaub asked 17/12, 2022 at 15:30

13

Solved

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 lik...
Jaf asked 28/2, 2014 at 11:25

8

Solved

I have a xUnit test like: [Fact] public async void GetLocationsCountAsync_WhenCalled_ReturnsLocationsCount() { _locationsService.Setup(s => s.GetLocationsCountAsync("123")).ReturnsAsync(10); ...
Pinto asked 24/7, 2018 at 1:10

5

Solved

I'm developing some end-to-end tests using C# with .NET Core, Selenium and NUnit. Now i want to write a login testcase. My tests are started from console simply by using the dotnet test command. I...
Dermatology asked 6/1, 2019 at 17:30

3

I have a problem writing my unit test in C# using Moq and xUnit. In my service I have the following code: var options = new TokenCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzurePublic...
Polybius asked 21/10, 2021 at 9:46

2

I am writing integration test using XUnit and my web api code is also in C# NET 6 and EF Core. When I debug it, it can reach the web api and its service layer. But when it reaches EF Core context q...
Cohabit asked 25/8, 2022 at 3:18

2

Solved

I have a function that I want to x-unit test, but it seems that I have to mock the CreateClient function? Whenever I debug it during testing it seems that the var client is equals to null. I am inj...
Stannite asked 15/1, 2019 at 13:40

6

Solved

I created a xUnit project to test this sample code public class ClassToTest { private readonly ILogger<ClassToTest> _logger; public ClassToTest(ILogger<ClassToTest> logger) { _logg...
Enyedy asked 21/2, 2021 at 21:46

4

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 ...
Complication asked 1/4, 2016 at 19:2

8

I want to pass an array of string to one of my XUnit test method, but when I just do the following it doesn't work (array + params mechanism) [Theory] [InlineData(new object[] { "2000-01-02&qu...
Esquimau asked 5/4, 2016 at 7:14

6

Solved

Before I start, I've tried all suggestions from the following and none work: Integration testing ASP.NET Core with .NET Framework - can't find deps.json https://zimmergren.net/unable-to-find-de...
Anetteaneurin asked 16/11, 2021 at 15:34

10

What are the differences between NUnit and xUnit.net? What's the point of developing two of them, not only one? I've read that xUnit is being developed by inventor of NUnit: xUnit.net is a unit te...
Adellaadelle asked 19/3, 2012 at 11:7

4

Solved

I have an Asp.net Core method with below definition. [HttpPost] public IActionResult Upload(IFormFile file) { if (file == null || file.Length == 0) throw new Exception("file should not be null")...
Phyllys asked 23/5, 2017 at 8:4

2

Solved

I use this code to load settings depending on Environment in my xUnit test project: public class TestSettings { public string AzureConnectionString { get; } public TestSettings(ITestOutputHelpe...
Methenamine asked 13/12, 2017 at 1:8

2

Solved

I want to compare a list of objects, ignoring the order of the objects in the list and only comparing some of the properties in the objects, currently I'm using the following code to perform this c...
Kanpur asked 20/3, 2013 at 0:20

2

Say I have a test: [Theory] [InlineData("one")] [InlineData("two")] public void ShouldSelectSingleTheoryFromDotnetTest(string s) { Assert.True(true); } I want to execute...
Konyn asked 25/1, 2021 at 12:41

1

Solved

Is it currently possible (and if so, how) to run unit tests from Visual Studio in Docker and get the results in the Test Explorer? I am having success using Visual Studio Tools for Docker and writ...
Crinkleroot asked 6/10, 2017 at 12:34

2

Solved

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 t...
Precancel asked 7/9, 2016 at 20:57

3

Solved

I'm trying to get a call to WriteAsync mocked on a mockHttpResponse and I can't figure out the syntax to use. var responseMock = new Mock<HttpResponse>(); responseMock.Setup(x => x.WriteA...
Kaylenekayley asked 27/4, 2018 at 15:2

1

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...
Storfer asked 14/3, 2023 at 22:58

© 2022 - 2024 — McMap. All rights reserved.