You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a test fails due to an exception it would helpful to have a "Jump to error" or "Fix" button that uses EDITSOURCE() to jump to the line of code that caused the error. Typically this error is not in the UnitTest, but in the tested class or some class that is used and not mocked. The button could be placed below the "Compare" button and only be enabled, when a test failed due to an exception.
The greatest obstacle to the implementation is FoxUnit's reliance on TRY...CATCH. A VFP exception only has method/procedure name and a line number. More detailed information such as the class library are not available and cannot be collected with ASTACKINFO() in the CATCH block as that is already after the fact.
FoxUnit could instead use the following alternative approach:
Do ____FoxUnit____Execute____TRY_CATCH_Handler
Procedure ____FoxUnit____Execute____TRY_CATCH_Handler
Private all like *____FoxUnit____
Dimension ____FoxUnit____AStackInfo[1]
____FoxUnit____Message = ""
____FoxUnit____Error = 0
____FoxUnit____Line = 0
____FoxUnit____OnError = On("Error")
On Error ____FoxUnit____HandleErrorException (Message(), Error(), Lineno(1), Program(-1))
Do UnitTest
On Error &____FoxUnit____OnError
Clear
List Memory like ____FoxUnit____AStackInfo
?
? ____FoxUnit____Message
? "error #", ____FoxUnit____Error, "in line", ____FoxUnit____Line
* Show source
Local lnLevel
lnLevel = Alen(____FoxUnit____AStackInfo,1) - 1
EditSource(____FoxUnit____AStackInfo[m.lnLevel,4], ____FoxUnit____AStackInfo[m.lnLevel,5])
EndProc
Procedure ____FoxUnit____HandleErrorException
LParameter tcMessage, tnError, tnLine, tnStackLevel
AStackInfo(____FoxUnit____AStackInfo)
Dimension ____FoxUnit____AStackInfo[m.tnStackLevel,6]
____FoxUnit____Message = m.tcMessage
____FoxUnit____Error = m.tnError
____FoxUnit____Line = m.tnLine
Return to ____FoxUnit____Execute____TRY_CATCH_Handler
Procedure UnitTest
Local loObject
loObject = CreateObject("SomeClass")
loObject.CauseError ()
MessageBox("Don't run this")
EndProc
Define CLASS SomeClass as Custom
Procedure CauseError()
Accept life, deal with it
EndProc
EndDefine
The text was updated successfully, but these errors were encountered:
When a test fails due to an exception it would helpful to have a "Jump to error" or "Fix" button that uses EDITSOURCE() to jump to the line of code that caused the error. Typically this error is not in the UnitTest, but in the tested class or some class that is used and not mocked. The button could be placed below the "Compare" button and only be enabled, when a test failed due to an exception.
The greatest obstacle to the implementation is FoxUnit's reliance on TRY...CATCH. A VFP exception only has method/procedure name and a line number. More detailed information such as the class library are not available and cannot be collected with ASTACKINFO() in the CATCH block as that is already after the fact.
FoxUnit could instead use the following alternative approach:
The text was updated successfully, but these errors were encountered: