Skip to content

Commit d97f962

Browse files
committed
fix: call superclass in TestCoverage.Manager so updates to %UnitTest.Manager will be propagated
1 parent adbe6ae commit d97f962

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.0.6]
9+
10+
### Fixed
11+
- #63: TestCoverage.Manager On/After methods now call superclass so improvements to %UnitTest.Manager like AutoUserNames will work properly
12+
813
## [4.0.5] - 2024-11-04
914

1015
### Fixed

cls/TestCoverage/Manager.cls

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ Method OnAfterSaveResult(ByRef userparam)
592592
{
593593
Try {
594594
Quit:'$IsObject(..Run)
595+
Do ##super()
595596

596597
// Associate to unit test results.
597598
Do ..Run.TestResultsSetObjectId(..LogIndex)
@@ -630,6 +631,7 @@ ClassMethod OnBeforeAllTests(manager As TestCoverage.Manager, dir As %String, By
630631
{
631632
Set tSC = $$$OK
632633
Try {
634+
Do ##super()
633635
Set tCoverageClasses = $Get(userparam("CoverageClasses"))
634636
Set tCoverageRoutines = $Get(userparam("CoverageRoutines"))
635637
Set tCoverageDetail = $Get(userparam("CoverageDetail"))
@@ -717,6 +719,7 @@ ClassMethod OnAfterAllTests(manager As TestCoverage.Manager, dir As %String, ByR
717719
{
718720
Set tSC = $$$OK
719721
Try {
722+
Do ##super()
720723
If (manager.CoverageDetail = 0) {
721724
Set tSC = manager.EndCoverageTracking()
722725
if (manager.ListenerManager) {
@@ -742,6 +745,7 @@ Method OnBeforeAutoLoad(dir As %String, suite As %String, testspec As %String, B
742745
{
743746
Set tSC = $$$OK
744747
Try {
748+
Do ##super()
745749
// TODO: Flag to capture code coverage of compiling autoload classes? (e.g., to cover generators?)
746750
} Catch e {
747751
Set tSC = e.AsStatus()
@@ -756,6 +760,7 @@ Method OnBeforeTestSuite(dir As %String, suite As %String, testspec As %String,
756760
{
757761
Set tSC = $$$OK
758762
Try {
763+
Do ##super()
759764
If ..DynamicTargets && (dir '= "") {
760765
// Determine coverage targets based on directory contents (looking for coverage.list in that directory or the nearest ancestor containing it).
761766
Set tSC = ..UpdateCoverageTargetsForTestDirectory(dir)
@@ -785,6 +790,7 @@ Method OnAfterTestSuite(dir As %String, suite As %String, testspec As %String, B
785790
{
786791
Set tSC = $$$OK
787792
Try {
793+
Do ##super()
788794

789795
If (..CoverageDetail = 1) {
790796
Set tSC = ..EndCoverageTracking($Case(suite,"":"(root)",:suite))
@@ -806,6 +812,7 @@ Method OnBeforeTestCase(suite As %String, class As %String) As %Status
806812
{
807813
Set tSC = $$$OK
808814
Try {
815+
Do ##super()
809816
Set ..CurrentTestClass = class
810817
Set ..CurrentTestMethod = ""
811818
if (..ListenerManager) {
@@ -829,6 +836,7 @@ Method OnAfterTestCase(suite As %String, class As %String) As %Status
829836
{
830837
Set tSC = $$$OK
831838
Try {
839+
Do ##super()
832840
If (..CoverageDetail = 2) {
833841
Set tSC = ..EndCoverageTracking(suite, class)
834842
}
@@ -850,6 +858,7 @@ Method OnBeforeOneTest(suite As %String, class As %String, method As %String) As
850858
{
851859
Set tSC = $$$OK
852860
Try {
861+
Do ##super()
853862
Set ..CurrentTestMethod = method
854863
if (..ListenerManager) {
855864
set tObj = {"message": "Starting test method: "}
@@ -873,6 +882,7 @@ Method OnAfterOneTest(suite As %String, class As %String, method As %String) As
873882
{
874883
Set tSC = $$$OK
875884
Try {
885+
Do ##super()
876886
If (..CoverageDetail = 3) {
877887
Set tSC = ..EndCoverageTracking(suite, class, method)
878888
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Class UnitTest.TestCoverage.Unit.Manager Extends %UnitTest.TestCase
2+
{
3+
4+
Parameter AutoUserNames As STRING = "TestA;TestB;TestC";
5+
6+
Method TestAutoUserNames()
7+
{
8+
// verify the 3 usernames are automatically created
9+
ZNSPACE "%SYS"
10+
11+
Do $$$AssertTrue(##class(Security.Users).Exists("TestA"))
12+
Do $$$AssertTrue(##class(Security.Users).Exists("TestB"))
13+
Do $$$AssertTrue(##class(Security.Users).Exists("TestC"))
14+
Do $$$AssertNotTrue(##class(Security.Users).Exists("TestD"))
15+
}
16+
17+
}

0 commit comments

Comments
 (0)