Question
· Jan 6, 2020

Is it possible to add an arbitrary key-value pair (property) into ^UnitTest.results?

Wondering whether it's possible to get %UnitTest to output an arbitrary key-value pair (a new property) into ^UnitTest.results ?

 

 

Discussion (10)2
Log in or sign up to continue

Could code within the unit test class set these additional fields in the new mapping table programatically?   

Sure, same as with any other object/table.

To get the Unit Test result ID anywhere in the tests call:

set id = $get(^UnitTest.Result,0)+1

Note, that I assume you're running only one test suite at a time. If that's not the case, you'll need to implement OnAfterSaveResult callback (preferable solution anyway) and ID would be available at that time as LogIndex poroperty.

looking at aggregating/classifying their results

This might be easier solved externally to unit tests themselves - by a separate task for example.

Not sure exactly what you're asking for...

You can add additional properties to your custom unit test class (inheriting from %UnitTest.TestCase) and use them to share data between the methods in the class. But this doesn't show up automatically in the results.

You can use the $$$LogMessage macro to display whatever you want in the results, but this is just text, not a new property.

do $$$LogMessage(key _ ":" _ value)