3,341 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
106
views
Visual Studio Test Explorer hangs indefinitely on .NET 10 xUnit project, but dotnet test passes
Problem Description: I am working on a simple console application (Advent of Code) using .NET 10. I have set up an xUnit test project.
The Issue: When I try to run tests in Visual Studio's Test ...
0
votes
0
answers
52
views
xUnit tests fail when launched from Solution Explorer
When I run my tests from the Solution Explorer (clicking "Run" from the tree), 13 tests from my test suite fail. This is 100% reproducible.
When launching the same tests from the Test ...
0
votes
0
answers
111
views
xUnit Testing in Testing Explorer
I'm trying to add tests to my MAUI app.
I added the xUnit test project to a separate namespace. The tests only run in the terminal with the dotnet test command.
If I use the test explorer, it doesn't ...
1
vote
1
answer
124
views
How to get an xUnit test to work with a simple console application
I've been referencing a post here on Stack Overflow Is there a way to unit test top-level statements in C#? However, it hasn't helped. I'm trying to learn how to use xUnit testing in a C# console ...
Rod's user avatar
- 4,583
5
votes
0
answers
247
views
`dotnet test` is inconsistent when it comes to showing the total number of unit tests at the end
I have a solution with many projects. When I run dotnet test, it selects all my xUnit projects and seems to correctly execute all of them. But at the last line of what dotnet test prints, the number ...
3
votes
1
answer
92
views
In xunit test catch block not executing after mocking
The code to be tested is as follows:
//pseudo code
public class ConnectionManager: IConnectionManager
(
ILogService _logService;
IConnector _iConnector;
public ConnectionManager(...
2
votes
2
answers
110
views
Are these unit tests using Moq testing anything?
I am attempting to test a repository method using a moq with a setup in the test. As far as I can tell, this is not testing the method but only testing the test.
Here is an abbreviated version of the ...
1
vote
1
answer
117
views
How to test .NET Core Console application which uses Dependency Injection using xUnit?
I have a console app constructed using the following code:
public partial class Program
{
private static async Task<int> Main(string[] args)
{
Host.CreateDefaultBuilder(args)
...
1
vote
0
answers
72
views
System.AccessViolationException occurs when running a C# Godot unit test for Node2D object
I am building a card game using Godot 4.5, with C#. I am trying to unit test a Card object that inherits from Node2D, but when I attempt to run the test, I get the following exception:
Exception has ...
1
vote
1
answer
106
views
Moq: how to create a HttpRequest object containing a HttpPostedFile?
I am working with ASP.NET/.NET 4.8 application.
My action method is as follows:
public class TestController: System.Web.Http.ApiController
{
// pseudo code
public async Task<...
0
votes
0
answers
110
views
xunit test in VSCode on Windows doesn't stop on breakpoint
I am trying to use XUnit for testing my f# code.
module UnitTest1
open Xunit
open Program
open System.Diagnostics
[<Fact>]
let Test1 () =
Debugger.Break()
Assert.True(true)
The test ...
2
votes
0
answers
74
views
Why does xUnit consider that a JToken is equal to all the numbers? [duplicate]
I'm using .NET9.0.
MRE:
public class JTokenEqualityTests
{
[Fact]
public void IntVsJToken_AssertEqual_ShouldFailButDoesnt()
{
int original = 42;
JToken token = JToken....
0
votes
0
answers
33
views
Pass `string[][]` as `InlineData to xUnit Theory? [duplicate]
In an xUnit theory I'd like to send an InlineData parameter of type string[][]. I can't seem to get it right. Is it doable, and if so, how?
I would expect this to work at least:
[InlineData(new string[...
1
vote
1
answer
126
views
JetBrains Rider changed diff tool used in Visual Studio. How to undo?
I have been using Visual Studio 2022 Enterprise for a while (version 17.14.12 at the moment).
When running unit tests, Verify.XUnitV3 used Visual Studio's internal diff tool when a test failed.
After ...
0
votes
0
answers
82
views
How to create integration tests with Keycloak and xUnit?
I'm creating a new project with Keycloak and .NET Core 9. I've managed to get it working with my application, but I need to make it work with my integration tests.
To integrate authorization and ...