question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to Hide the StackTrace of the Custom Extension Method on Assert.That From the Text Output Window?

See original GitHub issue

I’ve created my own extension methods on the non static Assert class usable via the Assert.That singleton in the expected manner I’m assuming is correct:

[DebuggerHidden]
public static void ExistsLineContaining(this Assert assert, string[] lines, string value, string message = null)
{
    Assert.IsTrue(lines.Count(l => l.Contains(value)) >= 1, message);
}

but when my test fails, the stack trace shows the ExistsLineContaining extension method as the first value in the trace: image

This is really not ideal. I can work around it slightly by putting it in a separate assembly, and turning off debug information from being generated, but this is again really not ideal, and it doesn’t solve the problem of the line from showing up in the test output (but at least it’s not clickable): image Is there any supported method to give these extension methods more of a “First Class” feel to them by preventing them from showing in the stack trace of the test output?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
karanjitsinghcommented, Feb 13, 2019

@daryllabar, Good question! It seems we exclude certain types from the stack trace here

Which made me realize that we have a workaround for you, all you have to do is keep your extension method under the namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter

image

image

Apologies for the confusion earlier!

0reactions
acesiddhucommented, Feb 20, 2019

Closing the issue. Please make changes as @karanjitsingh suggested

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to hide the current method from exception stack trace ...
The GetStackTraceWithoutHiddenMethods() extension method answer is fine, except that Exception.ToString() doesn't use the StackTrace property, ...
Read more >
Hide / Remove Stack Trace information - Microsoft Q&A
I have no idea what else is causing the stack trace to still ... but to hide/remove stack trace information for any error...
Read more >
See Improved Logging with Assert Class Methods
Reduced redundancy in stack trace output simplifies and clarifies logging. Previously, when some Assert class methods caused a test to fail, the logged...
Read more >
Managing pytest's output
The --full-trace causes very long traces to be printed on error (longer than --tb=long ). It also ensures that a stack trace is...
Read more >
Debug.Log and needless spam
Log includes stacktrace information that follows immediately after any custom message you specify. The Console just happens to show the first ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found