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

First test per class is running far slower than every other test

I am using VS 2019 with a unit testing project. I have about 80 tests in total, split across several test classes. I have noticed that when a class has several methods, that the first test takes 30ms or so to run and the others are 1ms or so. These…
Steven Sproat
  • 4,398
  • 4
  • 27
  • 40
1
vote
1 answer

How to get xUnit Current Test Name?

In nUnit we can get current test name like TestContext.CurrentContext.Test.Name that I am passing in Sauce Labs with ChromeOptions to show method name in saucelabs like below ChromeOptions options = new…
Ravi
  • 408
  • 7
  • 22
1
vote
1 answer

Mocking in C# Net Core 2.1 Function App with xUnit framework

I'm trying to write Unit Tests in C# .Net Core 2.1 Function App with xUnit framework for something like this, where the class variables are initialized through Autofac dependency injection. public class TestClass { private readonly…
tanmayghosh2507
  • 773
  • 3
  • 12
  • 31
1
vote
0 answers

How can I easily Ignore [] annotation?

I have many test code lines annotated with [] expression. However, when I run test with dotnet test command, they are not considered as active test cases. How can I easily convert them into active test cases?
dinggul
  • 11
  • 1
1
vote
1 answer

.Net Core 3.1 WebApplicationFactory TestServer: cannot find Razor view when override Startup

I am trying to write an integration test for a controller with a view. I do it as part of migration to .Net Core 3.1 from 2.2. There is a lot of configuration in ConfigureServices that we need to mock or disable in the tests, so, we derive from…
1
vote
1 answer

Change global defaults for .suo contents visual studio 17

How to set these settings globally, I am using xunit for testing and need to disable this every time I clone the repository for each project. As I found out this is stored in the .vs folder locally
cerahe3782
  • 39
  • 6
1
vote
2 answers

Assert duplicate element in unit testing

How can I to make a unit test check that a list of object not contains a duplicate element based on some properties. Here is what I tried to do: [Fact] public void RecupererReferentielContactClient_CasNominal_ResultOk() { // Arange var…
ucef
  • 557
  • 3
  • 10
  • 27
1
vote
1 answer

How to get the xUnit Fact Attribute 'DisplayName' argument inside the Fact test method

[Fact(DisplayName = "Test Demo Display Name")] [Trait("Category", "Internal")] [Trait("Category", "All")] public void Demo() { // I like to get the DisplayName 'Test Demo Display Name'…
Hashili
  • 113
  • 16
1
vote
1 answer

xUnit tests suddenly throwing exception System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter

I have an xUnit project that has run all tests flawlessly until now. I added two new test methods and now, suddenly, no tests can run because an exception is thrown: System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest…
J. Doe
  • 99
  • 1
  • 6
1
vote
1 answer

use mediator cqrs in TDD for integration test .net core 3

i use Mediator in my project . Demo Project on Github i want to use TDD in my project and integration test with .Net core 3.0 i write this code int test class for use intergration test with mediator : public class SubscribeTest :…
kia kia
  • 179
  • 1
  • 2
  • 9
1
vote
0 answers

Where and when should data be inserted into a database in the arrange phase in xunit framework?

Where and when should data be inserted into a database in the arrange phase in xunit framework? By the arrange phase I mean the Arrange from the Arrange, Act, Assert pattern. To prepare data for each test method I am using a separate class.…
hellouworld
  • 525
  • 6
  • 15
1
vote
1 answer

How to Mock Complicated Nested Member in Object or Keep as separate Variable?

I am writing to test an intricate class with complex nested calculations. We are looking at ActionMethod, and its returnType. The returnType is a complicated equation, how would I mock it? var methodInfoMock = new Mock(); var…
user12425844
1
vote
2 answers

How do I unit test an adapter class?

Suppose I have the following classes from a third-party library: public class ThirdPartyType { ... } public class ThirdPartyFunction { public ThirdPartyType DoSomething() { ... } } The implementation details are not important, and they are…
redcurry
  • 2,381
  • 2
  • 24
  • 38
1
vote
0 answers

How to use XUnit Collection Fixtures in ABP?

We have a .NET Core 2.2 project using ASP.NET Boilerplate 4.10.1. This project has a huge db context that takes way too long to load for each integration test we're running, so we'd like to see how it'd go with a shared context between…
Matheus Lacerda
  • 5,983
  • 11
  • 29
  • 45
1
vote
1 answer

How to use xunit to unit test contains the function of hangfire

The develop language is dotnet core 3.0. I dont't have idea.Help Me!Thanks a lot. The function like below : function test(){ BackgroundJob.Schedule((s) => s.HandleSettlementJob(recordId), TimeSpan.FromSeconds(60)); } I…
willim
  • 103
  • 2
  • 10