Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Can I add my own clickable file paths to the test failure output?
dylanbeattie
#1 Posted : Saturday, May 25, 2024 4:07:29 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2012(UTC)
Posts: 12
Location: London

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Hey. First up: NCrunch continues to be awesome and one of my absolute must-have programming tools. Yay. Thank you.

My latest .NET project is an interpreter for the Rockstar programming language, and frequently when a test fails, it's because of an error in the .rock program I'm running, not an error in my .cs code.

Is there any way I can prepend a clickable file path the NCrunch test output which I can click to jump to the file/line that contained the error?

I've tried outputting the full file path, both the _AppData\Local\NCrunch version and the D:\Projects\Rockstar\ version, but the UI doesn't render it as a clickable link.

I'm assuming the links in NCrunch's test output are based on the exception stack trace or something... I've tried messing around with the exception stack trace using reflection but didn't make much headway. Is there any easy way to add/prepend my own links to the output?

A screenshot of the NCrunch test output with a highlighted file path

Thanks,

Dylan
Remco
#2 Posted : Sunday, May 26, 2024 2:34:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi Dylan, thanks for posting, and for liking NCrunch so much :)

NCrunch internally replaces file paths with links when they point to files that are in the foreground solution (i.e. source files in your codebase). It actually doesn't matter what kind of source file they are, since we try to be as source agnostic as possible. The key thing is that they must be part of a project in your solution.

The file that isn't clickable here is pathed inside the NCrunch workspace rather than your solution itself. As such, it's in a temporary location used by NCrunch to build the project and run tests.

In the past we've tried to make it hard to open paths inside workspaces by making them clickable, because it then becomes extremely easy to mistake them for solution files and edit them unintentionally. When files in workspaces get changed, test and build results get desynced from the foreground solution and everything kind of falls apart.

Unless you have a way to make this file be a part of your foreground solution and have the link reference it there, I can't suggest a way to make this work for you.

Perhaps we could examine other options. Why do you need to examine this file? If you're generating it yourself, would it perhaps be worth writing its output to the test trace output? You could perhaps rig the test to automatically open an editor on the generated files when it gets run with a debugger attached (this is a trick I've used often myself).
dylanbeattie
#3 Posted : Sunday, May 26, 2024 11:06:20 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2012(UTC)
Posts: 12
Location: London

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Hey - that's what I thought; the first thing I tried was to Console.WriteLine the full path to a file that's part of my solution, but that doesn't turn it into a hyperlink. Here's an example where I've copied the exact same file path that's linked in the stack trace and Console.WriteLine()d it to see if NCrunch makes it clickable, but no:



(The files I'm linking to are .rock files; they *are* part of my test project, and I'm linking to them so I can jump straight from the test failure to the point in my Rockstar program where the parser failed to see the Rockstar code which caused the failure.)

Given in this example I'm using the exact same file path in two places and only one of them's getting hyperlinked, I'm guessing it's not the file path or format that's the problem, so what's the logic that identifies the text fragment which gets hyperlinked? Does it have to be in the exception stack trace or can it be anywhere in the test output?


Thanks!

Remco
#4 Posted : Sunday, May 26, 2024 12:01:35 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
This might feel a bit messy, but could you try it with an ' at ' prefix and an ' in ' keyword so that it looks the same as an exception line?
1 user thanked Remco for this useful post.
dylanbeattie on 5/26/2024(UTC)
dylanbeattie
#5 Posted : Sunday, May 26, 2024 1:20:06 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2012(UTC)
Posts: 12
Location: London

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Ah - that pointed me in the right direction. The linking is only triggered if there is a line of output which exactly matches /^ at .*in (path):line \d+\w$/

Exactly three spaces, "at", one space followed by any number of any character, the full file path, ":line", one or more spaces, one or more decimal digits, any amount of whitespace, linebreak.

Thanks!
1 user thanked dylanbeattie for this useful post.
Remco on 5/27/2024(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.044 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download