Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xUnit ITestOutputHelper output is not captured by .NET Test Log #6221

Open
neliason0 opened this issue Aug 24, 2023 · 4 comments
Open

xUnit ITestOutputHelper output is not captured by .NET Test Log #6221

neliason0 opened this issue Aug 24, 2023 · 4 comments
Assignees
Labels
Milestone

Comments

@neliason0
Copy link

Type: Bug

Issue Description

When running a test XUnit ITestOutputHelper output is not being written to the .NET Test Log.

Steps to Reproduce

Create a test that uses ITestOutputHelper
In that test use ITestOutputHelper's WriteLine method
Run a test in VS Code

Expected Behavior

Text from WriteLine method will be output to the .NET Test Log

Actual Behavior

Text is not output to the .NET Test Log

Environment information

VSCode version: 1.81.1
C# Extension: 2.0.413
Using OmniSharp: false

Dotnet Information .NET SDK: Version: 7.0.400 Commit: 73bf45718d

Runtime Environment:
OS Name: Mac OS X
OS Version: 13.5
OS Platform: Darwin
RID: osx.13-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.400/

Host:
Version: 7.0.10
Architecture: arm64
Commit: a6dbb800a4

.NET SDKs installed:
6.0.300 [/usr/local/share/dotnet/sdk]
7.0.400 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/usr/local/share/dotnet/]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Visual Studio Code Extensions
Extension Author Version Folder Name
csharp ms-dotnettools 2.0.413 ms-dotnettools.csharp-2.0.413-darwin-arm64
dotnet-test-explorer formulahendry 0.7.8 formulahendry.dotnet-test-explorer-0.7.8
php-debug xdebug 1.33.0 xdebug.php-debug-1.33.0
python ms-python 2023.14.0 ms-python.python-2023.14.0
remote-explorer ms-vscode 0.4.1 ms-vscode.remote-explorer-0.4.1
remote-ssh ms-vscode-remote 0.102.0 ms-vscode-remote.remote-ssh-0.102.0
remote-ssh-edit ms-vscode-remote 0.86.0 ms-vscode-remote.remote-ssh-edit-0.86.0
roslynator josefpihrt-vscode 4.4.0 josefpihrt-vscode.roslynator-4.4.0
vscode-docker ms-azuretools 1.26.0 ms-azuretools.vscode-docker-1.26.0
vscode-dotnet-runtime ms-dotnettools 1.7.0 ms-dotnettools.vscode-dotnet-runtime-1.7.0
vscode-intelephense-client bmewburn 1.9.5 bmewburn.vscode-intelephense-client-1.9.5
vscode-pylance ms-python 2023.8.40 ms-python.vscode-pylance-2023.8.40
vsliveshare ms-vsliveshare 1.0.5883 ms-vsliveshare.vsliveshare-1.0.5883
xml DotJoshJohnson 2.5.1 dotjoshjohnson.xml-2.5.1

Extension version: 2.0.413
VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:40:25.698Z)
OS version: Darwin arm64 22.6.0
Modes:

System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 4, 4, 4
Memory (System) 16.00GB (0.26GB free)
Process Argv --crash-reporter-id e0a1c241-08dd-40d0-bce0-8be750957fe9
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30803844
3biah626:30602489
89544117:30613380
a9j8j154:30646983
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
gsofb:30804716
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
synctok:30815622
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30812749

@neliason0 neliason0 changed the title xUnit ITestOutputHelper output is not captured by console xUnit ITestOutputHelper output is not captured by .NET Test Log Aug 24, 2023
@arkalyanms arkalyanms added this to the September milestone Aug 24, 2023
@dibarbet dibarbet modified the milestones: September, Next Sep 9, 2023
@lucastheisen
Copy link

As a temporary workaround, when you click Run Test in vscode, the test output does show the fully qualified test name which you can use in combination with dotnet test --filter from the console. For example:

Starting test run
[Failed] Test.Integration.Submitter.PythonSubmitterFacts+SubmitAsync.DumpTheConfigAndFail
    Message:
        Assert.False() Failure
        Expected: False
        Actual:   True
    Stack Trace:
           at Test.Integration.Submitter.PythonSubmitterFacts.SubmitAsync.DumpTheConfigAndFail() in /home/ltheisen/git/test/Test.Integration/Submitter/PythonSubmitterFacts.cs:line 37

Can be run with:

dotnet test --filter 'FullyQualifiedName=Test.Integration.Submitter.PythonSubmitterFacts+SubmitAsync.DumpTheConfigAndFail'

And that does still print the output written to ITestOutputHelper.

@devklick
Copy link

devklick commented Dec 8, 2023

This is very frustrating.

Similar to what @lucastheisen mentioned, you can run the test with dotnet test and include a filter on the FullyQualifiedName, however you also need to include the --logger parameter to tell the dotnet cli what kind of output to log.

Example:

dotnet test --filter 'FullyQualifiedName=TestNamespace.TestClass.TestMethod' --logger 'console;verbosity=detailed'

See docs for supported values.

I thought that maybe adding this --logger parameter to the Dotnet-test-explorer: Test Arguments settings would allow the output to show in the test output, but apparently not 😞

@AtunBetun
Copy link

Upvoting this, I also need this feature as my test suite does not output anything in VSCode

@DanteMarshal
Copy link

DanteMarshal commented Sep 12, 2024

I've been using the "run test" CodeLens to run tests for small code snippets quickly and rapidly when needed, and everything was fine until recently I needed to do that again just to find out that I have no output at all.
Now I either have to do an Assert.Fail in for every message I want to put out or I have to manually run the test on console with a --filter option.

Excuse my ranting; But this is apparently due to "C# Dev Kit" abomination of an extension that broke everything since the day it appeared. It seems that I can install that extension, run my tests using the Test explorer there, and see my outputs in a different panel (which I have to manually focus every single time I run a test), but that is even more inconvenient than running the tests manually on console, plus I need to add and enable this bulky extension which makes everything act like it's in Visual Studio (and if I wanted that experience I wouldn't have used VSCode at all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants