Skip to content

fix: call superclass in TestCoverage.Manager so updates to %UnitTest.Manager will be propagated #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.0.6]

### Fixed
- #63: TestCoverage.Manager On/After methods now call superclass so improvements to %UnitTest.Manager like AutoUserNames will work properly

## [4.0.5] - 2024-11-04

### Fixed
Expand Down
10 changes: 10 additions & 0 deletions cls/TestCoverage/Manager.cls
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ Method OnAfterSaveResult(ByRef userparam)
{
Try {
Quit:'$IsObject(..Run)
Do ##super(.userparam)

// Associate to unit test results.
Do ..Run.TestResultsSetObjectId(..LogIndex)
Expand Down Expand Up @@ -630,6 +631,7 @@ ClassMethod OnBeforeAllTests(manager As TestCoverage.Manager, dir As %String, By
{
Set tSC = $$$OK
Try {
Do ##super(.manager, .dir, .qstruct, .userparam)
Set tCoverageClasses = $Get(userparam("CoverageClasses"))
Set tCoverageRoutines = $Get(userparam("CoverageRoutines"))
Set tCoverageDetail = $Get(userparam("CoverageDetail"))
Expand Down Expand Up @@ -717,6 +719,7 @@ ClassMethod OnAfterAllTests(manager As TestCoverage.Manager, dir As %String, ByR
{
Set tSC = $$$OK
Try {
Do ##super(.manager, .dir, .qstruct, .userparam)
If (manager.CoverageDetail = 0) {
Set tSC = manager.EndCoverageTracking()
if (manager.ListenerManager) {
Expand All @@ -742,6 +745,7 @@ Method OnBeforeAutoLoad(dir As %String, suite As %String, testspec As %String, B
{
Set tSC = $$$OK
Try {
Do ##super(.dir, .suite, .testspec, .qstruct)
// TODO: Flag to capture code coverage of compiling autoload classes? (e.g., to cover generators?)
} Catch e {
Set tSC = e.AsStatus()
Expand All @@ -756,6 +760,7 @@ Method OnBeforeTestSuite(dir As %String, suite As %String, testspec As %String,
{
Set tSC = $$$OK
Try {
Do ##super(.dir, .suite, .testspec, .qstruct)
If ..DynamicTargets && (dir '= "") {
// Determine coverage targets based on directory contents (looking for coverage.list in that directory or the nearest ancestor containing it).
Set tSC = ..UpdateCoverageTargetsForTestDirectory(dir)
Expand Down Expand Up @@ -785,6 +790,7 @@ Method OnAfterTestSuite(dir As %String, suite As %String, testspec As %String, B
{
Set tSC = $$$OK
Try {
Do ##super(.dir, .suite, .testspec, .qstruct)

If (..CoverageDetail = 1) {
Set tSC = ..EndCoverageTracking($Case(suite,"":"(root)",:suite))
Expand All @@ -806,6 +812,7 @@ Method OnBeforeTestCase(suite As %String, class As %String) As %Status
{
Set tSC = $$$OK
Try {
Do ##super(.suite, .class, .testcase)
Set ..CurrentTestClass = class
Set ..CurrentTestMethod = ""
if (..ListenerManager) {
Expand All @@ -829,6 +836,7 @@ Method OnAfterTestCase(suite As %String, class As %String) As %Status
{
Set tSC = $$$OK
Try {
Do ##super(.suite, .class, .testcase)
If (..CoverageDetail = 2) {
Set tSC = ..EndCoverageTracking(suite, class)
}
Expand All @@ -850,6 +858,7 @@ Method OnBeforeOneTest(suite As %String, class As %String, method As %String) As
{
Set tSC = $$$OK
Try {
Do ##super(.suite, .class, .method)
Set ..CurrentTestMethod = method
if (..ListenerManager) {
set tObj = {"message": "Starting test method: "}
Expand All @@ -873,6 +882,7 @@ Method OnAfterOneTest(suite As %String, class As %String, method As %String) As
{
Set tSC = $$$OK
Try {
Do ##super(.suite, .class, .method)
If (..CoverageDetail = 3) {
Set tSC = ..EndCoverageTracking(suite, class, method)
}
Expand Down
17 changes: 17 additions & 0 deletions internal/testing/unit_tests/UnitTest/TestCoverage/Unit/Manager.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Class UnitTest.TestCoverage.Unit.Manager Extends %UnitTest.TestCase
{

Parameter AutoUserNames As STRING = "TestA;TestB;TestC";

Method TestAutoUserNames()
{
// verify the 3 usernames are automatically created
ZNSPACE "%SYS"

Do $$$AssertTrue(##class(Security.Users).Exists("TestA"))
Do $$$AssertTrue(##class(Security.Users).Exists("TestB"))
Do $$$AssertTrue(##class(Security.Users).Exists("TestC"))
Do $$$AssertNotTrue(##class(Security.Users).Exists("TestD"))
}

}
Loading