Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [xunit]

The tag has no usage guidance.

0 votes
3 answers
139 views

.Net 8 XUnit: How to mock MySql in a CQRS API using integration tests?

This is a rewrite of my own .Net 8 XUnit: Should my tests use real data or how to mock MySql with CQRS? in a much more clear way: The reason for rewriting my previous question is because in the ...
Diego Perez's user avatar
3 votes
2 answers
359 views

.Net 8 XUnit: Should my tests use real data or how to mock MySql with CQRS?

I'm creating tests for our .Net 8 API. We use MySql for data storage and CQRS pattern for queries. In my personal opinion, I shouldn't use the real database for testing, because you will use an ...
Diego Perez's user avatar
1 vote
3 answers
158 views

Creating Unit and Integration Tests with Database elements

This is something that I've heard a number of opinions and theories about, but I'm still torn on how to go forward. For context, this particular issue deals with the following technologies, in case ...
CrystalBlue's user avatar
122 votes
19 answers
15k views

What is the point of unit tests?

I've been a software developer for 20+ years, although it's been an unusual career. I've mostly worked on either legacy projects, or small standalone, non-public-facing apps and so only a couple of ...
Edwardo's user avatar
  • 957
0 votes
1 answer
278 views

Best practice when it comes to using XUnit and prepping/ rolling back test accounts before and after running tests

I am writing integration tests via unit tests by using Xunit. (the specific testing framework is not set in stone, Xunit is being used simply because it has been used before in this project team) The ...
Robin's user avatar
  • 103
20 votes
8 answers
8k views

Why assert for null on a object before asserting on some of its internals?

Let's consider the following test. [Fact] public void MyTest() { // Arrange Code var sut = new SystemWeTest(); // Act Code var response = sut.Request(); // Assert ...
BAmadeusJ's user avatar
  • 326
66 votes
5 answers
21k views

Is the usage of random values in unit testing a good practice? [duplicate]

Having worked in complex solutions that had Unit Tests and Integration Test in the CI/CD pipeline, I recall having a tough time with tests that failed randomly (either due to random values being ...
Vinicius Scheidegger's user avatar
4 votes
2 answers
2k views

Unit testing a generic method not caring about the generic type

I have the following code public class MyCollection<T> { public void Add(T obj) { ... } public int Count { get; } } and the following unit test to check whether Add increases the Count ...
user avatar
1 vote
4 answers
3k views

Should Unit Tests share the Same Data set?

We are writing application service tests across our Data Service Class. Currently writing tests liking add Product, remove Product, check for inventory after sale, etc. They are all using the same ...
user avatar
-1 votes
1 answer
177 views

Should I have “shouldfail” unit test and “shouldpass” for all methods in TDD?

Here is my class library code which I have C# and xUnit. namespace XUnitSample.ClassLib { public class DataAccess : IDataAccess { public void AddPersonToPeopleList(List<Person> ...
Steve's user avatar
  • 299
1 vote
1 answer
453 views

xUnit and MOQ Code Structure and Setup in C# .NET Core

I am trying to create a simple setup for xUnit. At the moment, the function does not access to database. So, here is my structure: I have 2 projects in my solution. First is my class library which is ...
Steve's user avatar
  • 299
-2 votes
1 answer
58 views

Xunit TDD - second rule

What is the meaning of: You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failure by Robert Martin on TDD? Is it write only the needed ...
Steve's user avatar
  • 299
4 votes
2 answers
5k views

Are in-memory database a form of integration tests?

I have looked through most of the answers given regarding using in-memory database for unit test, but I could not find one that was clear to me. I am writing some unit tests to cover some of our ...
elfico's user avatar
  • 153
0 votes
3 answers
559 views

Is this proper way to unit test?

I'm trying to unit test some repositories and have no idea what I'm doing if someone could point in the right direction that would be good, currently, I'm testing behaviour of creating a new user ...
bonivip695's user avatar
0 votes
1 answer
203 views

Unit/Component testing using In Memory DB

I am writing Unit/Component test using In Memory DB. When I write Unit/Component test, I came across with the following question. I have the following two BL methods. ToCreate ToGet So when I ...
Jeeva Jsb's user avatar
  • 101

15 30 50 per page