Julian
Julian

Reputation: 36820

`dotnet test` - exception stacktrace without /agent/_work/1/s

When I get an exception during dotnet test on Azure DevOps, the stacktrace is printed.

Current output:

 Failed MyTest [54 s]
  Error Message:
   System.Exception: Parse failed
  Stack Trace:
     at MyTests.End2End.LocatorExtensions.InputValueAsEnumAsync[T](ILocator locator, LocatorInputValueOptions options) in /agent/_work/1/s/Backend/MyTests/End2End/Extensions/LocatorExtensions.cs:line 60
   at MyTests.End2End.Pages.MyPage.Assert(IReadOnlyList`1 allJaarcijfers) in /agent/_work/1/s/Backend/MyTests/End2End/Pages/MyPage.cs:line 81

Unfortunately, the path contains the prefix /agent/_work/1/s and as result, clicking the line in the test panel (in Azure DevOps) won't navigate correctly.

It is possible to get the stack trace lines without the /agent/_work/1/s?

e.g.

/agent/_work/1/s/Backend/MyTests/End2End/Pages/MyPage.cs:line 81

should be

/Backend/MyTests/End2End/Pages/MyPage.cs:line 81

Could we configure this with dotnet test, MS build properties or somewhere in Azure DevOps?

I'm using C#, .NET 8, xUnit 2.8.1 and Azure DevOps Services

Upvotes: 0

Views: 112

Answers (1)

Miao Tian-MSFT
Miao Tian-MSFT

Reputation: 5652

There is no direct method to eliminate the /agent/_work/1/s prefix from the stack trace. This prefix is a component of the file path where the Azure DevOps agent executes the tests and is incorporated into the stack trace by the .NET runtime.

I tested the issue in my pipeline, and I can reproduce your issue. When click the stack trace in the test tap, it will navigate to a File not found page.

ubuntu

ubuntu

Workaround

I found when I changed the vmImage from ubuntu-latest to windows-latest, it will navigate to the correct line of the file.

windows

I also tested with the macOS agent and found the same issue.

Currently, it seems that only the paths of Windows agents can be navigated correctly. I have created a ticket to report the bug. You can follow it for the update.

Upvotes: 0

Related Questions