-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix: add complete error info to test:run failures #125
Conversation
const stackTrace = syncRecord.stackTrace; | ||
const lineIndex = stackTrace.indexOf('line'); | ||
const colIndex = stackTrace.indexOf('column'); | ||
const line = stackTrace.substring(lineIndex + 5, lineIndex + 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems easy to break if the stacktrace characters do not match the parsing you are doing, which would later cause some problems when casting them into a number. Why do we want to parse the stacktrace like this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, if the exception message doesn't contain 'line' or 'column' we would run into issues. I can update it to return a default value in the event that line/col info wasn't present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not only that, if the number after line
or column
is more than one character we'll be parsing it incorrectly. That's why I want to know if we need to parse this info or can we just push what we get from the server all the way to the user. Can you provide a sample of what we get from the server/api ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on switching this to a regular expression that should address the number issue. The response from the server generally has an exception message: System.AssertException: Assertion Failed
and a stacktrace Class.MyApexTriggerTest.testExceptionThing: line 14, column 1
. I think these two provide enough information about the errors, so we could just push it all the way to the user - but I also wanted to create a diagnostic that could be used in VS Code to add info to the 'Problems' tab.
From what I can tell, we weren't utilizing the 'Problems' tab for test runs earlier because the cli command itself was building a "file map" of the files in the user's package directory. The filepath associated with the error was formatted for source links in VS Code and displayed in a separate table like this:
If we don't want to parse the error/stacktrace that we get from the server at this point, then that's something we would need to do in VS Code so we can still provide the user with a source link to navigate to the issue. Alternatively, we parse & build the whole source link here in the library like the cli command was doing..... 🥴
public getAsyncDiagnostic(asyncRecord: ApexTestResultRecord): ApexDiagnostic { | ||
const lineIndex = asyncRecord.StackTrace.indexOf('line'); | ||
const colIndex = asyncRecord.StackTrace.indexOf('column'); | ||
const line = asyncRecord.StackTrace.substring(lineIndex + 5, lineIndex + 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same parsing concern as with getSyncDiagnostic
}; | ||
|
||
const matches = asyncRecord.StackTrace.match(/(line (\d+), column (\d+))/); | ||
if (matches && matches[2] && matches[3]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a scenario where we get line
info but not column
and vice versa ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I haven't run into that scenario, but I can separate the if statements just to be on the safe side
What does this PR do?
This PR adds stacktrace information and a diagnostic util to any test failure results
It also sets the default value to 0 for any "time" related fields in the test:run output.
What issues does this PR fix or reference?
#2892, #2890, @W-8790874@
Functionality Before
Functionality After