Questions tagged [xunit]

xUnit is the collection name for unit-testing compliant frameworks following a specific architecture. Implementation differs from language to language but the framework should consist of a Test Runner, Test Case, Test Fixture (Context), Test Suite, Test Execution, Test Result Formatter and Assertions

xUnit has been implemented for most languages, examples include JUnit, NUnit, CUnit, CppUnit, xUnit.net and more. The first implementation was made for Smalltalk by Kent Beck and is called SUnit.

3147 questions
1
vote
0 answers

Test Explorer cannot discover any unit tests in VS2019

I have .NET core unit test projects which use xunit package in Visual studio 2019, but I found that the unit tests cannot be discovered in the Test Exporer window, and there is below info in the Output-> Test pane. I have tried the below workaround…
Carlos Liu
  • 2,348
  • 3
  • 37
  • 51
1
vote
1 answer

Convert DeploymentItem from MSTest to xUnit

I'm migrating MSTest cases to XUnit and couldn't find a way to convert DeploymentItem attribute of MSUnit to equivalent in XUnit. Please let me know how to migrate it. [DeploymentItem("Test Data", "Certificates")] Thanks in advance.
1
vote
1 answer

How to do UnitOfWork + Repository patterns with entity framework core and unit testing

I'm running into an issue while unit testing where if I run multiple tests at once, the DbContext will lose track of records I've added during unit tests and I think this may have to do with how services are registered in my ServiceCollection. I…
uioporqwerty
  • 1,068
  • 3
  • 12
  • 30
1
vote
1 answer

XUnit - run tests serially

I created few tests in XUnit (.NET CORE 5) Here is my code: public class SerialTest { [Fact] public async Task Test1() { await Task.Delay(TimeSpan.FromSeconds(5)); Assert.True(true); } [Fact] public async…
MrRav3n
  • 85
  • 6
1
vote
1 answer

Azure build project missing in code coverage

I have a build for xunit test. the build work, all test pass. But my code coverage file does not contain my master projects. I try with an empty runsettings file, I got a lot of none important dll/project, but I got some important project…
forX
  • 2,063
  • 2
  • 26
  • 47
1
vote
2 answers

Xunit test, creating a user

Hey im trying to make this unit test work but it says, A test class may only define a single public constructor. but im not quite sure what to do or what im doing wrong? using Application; using Domain.Models; using Infrastructure; using…
Christian
  • 11
  • 5
1
vote
1 answer

Mock repository method failed verify test

I'm using Moq framework and xUnit in .NET Core application. I have a mock of the repository public interface IItemRepository { string Add(T entity); } I want to test the method of the class, which is using this repository public…
1
vote
1 answer

Issue while Unit Testing ASP.Net Core with Mediatr

I am using ASP.Net Core 3.1 Repository Pattern and Unit of Work Using Dapper . I have use mediator as using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; namespace…
1
vote
0 answers

C# XUnit test event with custom delegate without EventArgs

I am currently writing tests for my .net framework 4.8 wpf application. I have a few events of the style public event CustomEventHandler ValueChanged; public delegate void CustomEventHandler(double newValue); XUnit has a function to test…
b.holz
  • 237
  • 3
  • 17
1
vote
1 answer

How to create private dependency method setup using Moq

I have the following Controller interface: public interface IInformationController { string GetStoredInformation(); string GetInformation(); } The controller class is the following: public class InformationController : ControllerBase,…
Nestor
  • 8,194
  • 7
  • 77
  • 156
1
vote
0 answers

xUnit - Functional Tests open loads of browser instances with data; in URL

I am having an issue running xUnit functional tests on a ASP.net core application. I am struggling to run these tests in parallel, as each test can open a 13 browser instance each and they do not complete as too much memory is consumed. Below is the…
Michael Thompson
  • 83
  • 1
  • 1
  • 8
1
vote
4 answers

Unit test a .NET Core app that requires Docker

I have a .NET Core project and a xUnit project to test it. I later added support to Docker to my main .NET Core project. I target Linux and I added a bunch of operations in my Docker file. My Docker image is hosted on Docker Desktop for Windows. My…
1
vote
0 answers

Unit tests are inconclusive when adding xUnit project to Unity project

I create a new Unity project and make sure the Assembly-CSharp.csproj file exists by creating a script in the Assets folder. I open that script and edit it to public class AScript : MonoBehaviour {} I close the IDE and Unity after that. The…
Question3r
  • 2,166
  • 19
  • 100
  • 200
1
vote
1 answer

XUnit Create Operation Service Mock Failure

I am trying to mock my service's create method like this in the class constructor: serviceMock.Setup(p => p.AddClinic(GetTestClinicModel())) .Returns(GetTestClinic()); Mock Model and Mock Entity private CreateClinicBindingModel…
tcetin
  • 979
  • 1
  • 21
  • 48
1
vote
1 answer

MOQ SetupGet dbContext with constructor parameters

Situation Here I am, trying to write some unit tests for my GroupService with the use of MOQ. To create an instance of my GroupService, I mocked 4 interfaces that needed to be passed through the constructor. Now on one of the mocks…
Svenmarim
  • 3,633
  • 5
  • 24
  • 56