Skip to main content
Software Engineering

Questions tagged [xunit]

The tag has no summary.

Filter by
Sorted by
Tagged with
0 votes
5 answers
394 views

Simulating different times of day when running integration tests, .NET/XUnit

I work on an organization's internal .NET Core 8 application where various dates are stored in different canonical formats, and some comparisons (checking that the current moment falls between a data ...
0 votes
3 answers
227 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 ...
3 votes
2 answers
650 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 ...
1 vote
3 answers
777 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 ...
128 votes
19 answers
19k 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
  • 1,017
0 votes
1 answer
461 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
9k 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 ...
71 votes
5 answers
24k 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 ...
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
user277671
1 vote
4 answers
4k 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
user375708
-1 votes
1 answer
190 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
  • 309
1 vote
1 answer
509 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
  • 309
-2 votes
1 answer
63 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
  • 309
4 votes
2 answers
6k 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 ...
0 votes
3 answers
631 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 ...

15 30 50 per page
1
2

AltStyle によって変換されたページ (->オリジナル) /