Questions tagged [dotnet-test]
63 questions
4
votes
1 answer
How can I properly generate both TRX files and code coverage results with one call to "dotnet test"?
First, some context: I have a Visual Studio solution containing several production class libraries and nine unit test projects. All the projects are targeting .NET 5. I am running .NET 5.0.401. All unit test projects have references to…

NathanAldenSr
- 7,841
- 4
- 40
- 51
4
votes
1 answer
Pass multiple tests names in "dotnet test --filter" option
I am trying to rerun failed tests using dotnet test command. I want to pass a list of failed tests from a file created during test run. I can't seem to get the '&' operator syntax right for the "--filter" option. I am able to pass only one test name…

Noam Igor Veronin
- 163
- 2
- 12
4
votes
2 answers
dotnet test does not recognize xunit tests
I know that this question has been asked multiple times before I raise it again, However I still could not get the answer for dotnet 5.0 and xunit
What have I tried.
I have the following test defined
public class IntegrationTests
{
[Theory]
…

frictionlesspulley
- 11,070
- 14
- 66
- 115
3
votes
0 answers
Generate xUnit test results in .json format
Currently, I'm running a set of xUnit test using the following command:
dotnet test --filter TestType=$testType --logger trx
Is there a way to generate results in json format? Something like --logger json?
Thank you.

Stefan Rasevic
- 31
- 2
3
votes
0 answers
Azure Pipelines and Xunit Together
I am trying to track down a bug in my Xunit acceptance tests on Azure Pipelines and want to enable stoponfail to make the problem easier to track down. It's an intermittent timing thing, so hard to reproduce running tests locally.
I have the…

Jeff
- 35,755
- 15
- 108
- 220
3
votes
2 answers
How to pass multi-valued arguments containing commas to a property in dotnet command line tool?
I want to run a command that includes this:
dotnet test /p:Exclude=\"*Test*,*Requirement*\"
The above is not the full command, but it's enough to provoke the parsing error. I am using the Coverlet NuGet package in my C# project and I want to exclude…

Claus Appel
- 379
- 1
- 4
- 13
3
votes
1 answer
Break PowerShell Script when dotnet test fails
In a small PowerShell build script I build and test a .NET application.
I now want to prevent further steps in the script if the tests result in one or more failures.
I tried to get the result of the test like this:
$exitcode = dotnet test …

Boas Enkler
- 12,264
- 16
- 69
- 143
2
votes
1 answer
ASP.NET Core WebApplicationFactory using InternalsVisibleTo does not work in xunit
I originally posted a question on the asp.net docs and was referred here.
Moving from NET5 -> NET6 broke a lot of testing using the WebApplicationFactory since the public Startup.cs was removed. The alternative was moving to Program which worked…

Max Hamulyák
- 228
- 1
- 7
2
votes
0 answers
NETSDK1013: The TargetFramework value 'v4.7.2' was not recognized
I am running unit tests on a .NET project against a specific version of .NET framework and I am using following command:
dotnet test --framework v4.7.2
But when running this, I am getting following…

StandardProc
- 85
- 1
- 8
2
votes
0 answers
Upload coverage information to SonarCloud from coverlet for C# project
I'm trying to collect coverage info and publish it to SonarCloud for my C# project, using GitHub Actions as my CI pipeline. The execution is very simple, basically trying to execute tests for all projects, merging all coverage files:
run: |
…

Peter Lenkefi
- 1,306
- 11
- 29
2
votes
1 answer
Passing an extremely long filter to dotnet test?
I am trying to pass an extremely long filter to dotnet test --filter. However, it is so long, that I get a "path too long" error.
Is there any other way to specify a filter?
Or alternatively somehow "pipe" a filter from a file into the --filter…

Mathias Lykkegaard Lorenzen
- 15,031
- 23
- 100
- 187
2
votes
1 answer
`dotnet test` capturing garbage characters which mess up the output - need to remove
I am similar issue to expect script capturing garbage characters - need to remove. Logs and console output contain these ANSI escape sequences and messing up with the resulting output. It became difficult to understand what is going on in actual…

pmunshi
- 21
- 4
2
votes
1 answer
Dotnet test ignoring filter when on Linux
I'm using xunit, with trait attributes set on some of my tests. When running dotnet test I'm trying to filter by these traits. I have it working fine locally on my Windows machine but when I run the same command on my CI container then it doesn't…

Matt Keen
- 329
- 3
- 8
2
votes
1 answer
How to pass "workers" parameter to nunit runner when running "dotnet test" for a .net core 2.2 project
Currently, for our selenium UI tests, we are reading the available selenium server browsers to decide on the number of threads we will run our tests with and we pass the "workers" parameter when starting nunit console runner.
I am now migrating our…

Stoyan Kolev
- 101
- 1
- 9
1
vote
1 answer
dotnet test command logger only writes outputs of the last test when solution with multiple projects is specified to be tested
While trying to automate my MSTest based tests using dotnet test command I am experiencing an issue where only the outputs of the last test project run (in the solution) are written to the specified logger output
I have tried running the command…

ismar agilent
- 31
- 4