Yes I mean if we write a new test suite, I'm just wondering how, when running the tests, we could get the result to contain a new property (such as 'owner' or 'category')
To be more specific about what I'm trying to do: it's to generate a new field/value in %UnitTest_Result.TestSuite in addition to Name, TestInstance, ID, Duration, ErrorAction, ErrorDescription, Status which appear to be available by default.
Thank you for the response! Could code within the unit test class set these additional fields in the new mapping table programatically? (Sorry, am a bit unfamiliar with %UnitTests, just looking at aggregating/classifying their results).
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.
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.
As far as what I'm trying to do: it's to generate a new field/value in %UnitTest_Result.TestSuite in addition to Name, TestInstance, ID, Duration, ErrorAction, ErrorDescription, Status which appear to be available by default.
What do you want to achieve?
Is it possible to add another test suite and use that?
Yes I mean if we write a new test suite, I'm just wondering how, when running the tests, we could get the result to contain a new property (such as 'owner' or 'category')
To be more specific about what I'm trying to do: it's to generate a new field/value in %UnitTest_Result.TestSuite
in addition to Name, TestInstance, ID, Duration, ErrorAction, ErrorDescription, Status which appear to be available by default.
The easiest way to do that is to create a separate table which refers to Unit Test as a property and set additional fields there.
Thank you for the response! Could code within the unit test class set these additional fields in the new mapping table programatically? (Sorry, am a bit unfamiliar with %UnitTests, just looking at aggregating/classifying their results).
Sure, same as with any other object/table.
To get the Unit Test result ID anywhere in the tests call:
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.
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)
Thanks Joel for the reply; that is helpful.
As far as what I'm trying to do: it's to generate a new field/value in %UnitTest_Result.TestSuite in addition to Name, TestInstance, ID, Duration, ErrorAction, ErrorDescription, Status which appear to be available by default.
%UnitTest.Result.* classes are marked as final.
Social networks
InterSystems resources
To leave a comment or answer to post please log in
Please log in
To leave a post please log in