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
1 answer

Cannot convert Dynamic table entity to System.threading entity in assert

I am trying to implement an Assert over my function which is called in separate project. The function called is as follows: public async Task> PopulateTable( string documentId, IEnumerable lines, …
user2248618
1
vote
0 answers

An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL

I have a problem with running automated tests. When I run single tests, everything is ok, but when I run a package of the test, then I get fail with info: OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP…
Misieqj
  • 11
  • 3
1
vote
0 answers

How to dynamically load xunit tests?

I have a set of tests that are loaded dynamically using the ClassData decorator: using Xunit; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Interactions; using System.Collections.Generic; namespace…
1
vote
1 answer

.Net Core 3.1 Xunit runnig tests causes stack overflow error when I create new Custom FluentValidator object in fixture class

I am trying to write a test class to test my validators but I am getting an error will be described below. I have an test class to test my entities which are only have properties and class is empty for now. using Xunit; namespace…
NoStuff
  • 63
  • 9
1
vote
1 answer

How can I mock the Parent accessor of a faked TreeNode in a unit test?

Using Kentico 12 SP, hotfix 64 - I can create faked TreeNode types and set values on most of the fields, but I can't set a return value for Parent which I need to do to run a test on a method. The method I'm trying to test: public Dictionary
cganickel
  • 76
  • 6
1
vote
3 answers

How to get the name of the instance disposed by using reflection

I am building some integration tests for my database stored procedures. I have setup an xUnit project and implemented Fixture pattern. To show you: public class MyTableTest : IClassFixture { public MyTableTest() { …
Tarta
  • 1,729
  • 1
  • 29
  • 63
1
vote
1 answer

How to Set the content for HttpResponseMessage during a unit test?

I am writing a unit test in which I am testing a service that connects to an external service. Service code: var request = new APIRequest { Query = query }; var response = await _httpService.SendRequestAsync(_configuration.ApiUrl,…
ankur
  • 4,565
  • 14
  • 64
  • 100
1
vote
1 answer

Perform xUnit Moq test to create record and save it to DbContext

I am writing test for Web API application written in .NET CORE 3.1. I am using xUnit, AutoFixture & Moq for testing. I have a class that creates a new school instance in the database using Entity Framework/ DbContext. My question is how to mock…
K.Z
  • 5,201
  • 25
  • 104
  • 240
1
vote
1 answer

How to close Resharper test runner after finishing integration test in xUnit Test project (.NET Core)?

i am new to integration tests. I have an xUnit project in my solution which contains one test only. Here's the definition of my test: [Fact] public async Task ShouldCreateUser() { // Arrange var createUserRequest = new CreateUserRequest …
Bulchsu
  • 580
  • 11
  • 33
1
vote
1 answer

xUnit ClaimsPrincipal mock and passing into controller User is null

I have been reading articles trying to figure this one out. Structured off of this article How to add claims in a mock ClaimsPrincipal. I am still getting a null user from my controller and test fails on a null object of User inside the…
Ramious
  • 325
  • 1
  • 3
  • 16
1
vote
1 answer

XRay and XUnit reporter parses multiple test case attributes incorrectly

I'm trying to run these selenium tests with multiple Tms attributes and member data. The aim is to generate XUnit report and import it to XRay test execution ticket. [Theory] [Tms(4045)] [Tms(4081)] [Trait("Category",…
Max Vasiuta
  • 31
  • 1
  • 5
1
vote
1 answer

XUnit Testproject hits no Breakpoints while debugging

This seems to be a similar problem like Visual Studio "Debug Unit Test" fails to hit breakpoints But his fixes didn't work for me. VS2019 Professional, XUnit: I'm programming a server backend with controllers, I setup a new project for the test…
Crait
  • 11
  • 2
1
vote
2 answers

Mocking in Xunit- How to verify method that returns some value

I have created a unit test method that verifies method is called, below is the code for the same.The method builds email object and calls GeneratePDF method which returns bytes further BuildEmailInfo method returns email object. public class…
Vishal Dhasal
  • 51
  • 1
  • 10
1
vote
2 answers

xUnit + Unquote testing: report the first item where lists differ enough

I am writing a numerical differential equation solver. In my tests, I need to compare the list of actual values, produced by my code, and a list of expected values computed from the analytical solution, and detect if and when the two lists deviate…
Riccardo Orlando
  • 207
  • 2
  • 10
1
vote
1 answer

How to mock CreateBatchWrite object in Xunit

I’m writing a unit test in c# and I need to mock the response of CreateBatchWrite using Moq but not able to instantiate an object of the BatchWrite object. I’m doing this: _dbContext.Setup(m =>…
Biswajit Maharana
  • 531
  • 1
  • 8
  • 23