Determining whether a class, which you only have the name of, is a unit test class... I know this code sucks; but how to fix it properly?
Hello,
Here's the code:
Method isTestClass(className As %String) As %Boolean
{
if (className = ..#UTCLASS) {
return 1
}
#dim c as %Dictionary.ClassDefinition
#dim status as %Status
set c = ##class(%Dictionary.ClassDefinition).%OpenId(className,,.status)
if ($$$ISERR(status)) {
throw ##class(%Exception.StatusException).CreateFromStatus(status)
}
if ('c.SuperIsDefined()) {
return 0
}
#dim children
#dim len as %Integer
#dim i as %Integer
set children = $listFromString(c.Super, ",")
set len = $listLength(children)
for i = 1:1:len {
if ..isTestClass($listGet(children, i)) {
return 1
}
}
return 0
}
One thing which bothers me here is that I do not "close" the %Dictionary.ClassDefinition object; I believe this to be a problem somewhat, is that the case?
Second, I believe my walking the list of extended classes is not optimal either... Any way to do better?
Finally, and for some reason, I get errors from this code which I can't quite figure out... "Unable to load object", #5809... But from what I see this should not happen :(