How to Hide the StackTrace of the Custom Extension Method on Assert.That From the Text Output Window?
See original GitHub issueI’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:
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): 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:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
Apologies for the confusion earlier!
Closing the issue. Please make changes as @karanjitsingh suggested