Skip to content

Fix CodeCoverageTracker.Clear and silent null from TestSuiteManager - #101

Merged
josef-poetzl merged 2 commits into
devfrom
feature/suite-error-handling
Nov 18, 2026
Merged

josef-poetzl merged 2 commits into
devfrom
feature/suite-error-handling

Conversation

@josef-poetzl

Copy link
Copy Markdown
Member

Changes

  • CodeCoverageTracker.Clear(string codeModuleName = null) threw a NullReferenceException for the default value. Null or empty now clears all modules; Clear(name) also removes the module from the tracker, so the report no longer lists it.
  • TestSuiteManager.InitTestSuite only showed the exception and returned a null suite, so VBA failed later with a meaningless message. The exception is now logged and rethrown as InvalidOperationException("AccUnit test suite could not be initialized: <original message>"). TestSuiteInitialized is raised only on success. TestListAndResultManager shows the exception itself when creating the test window; TestStarter already caught it.
  • InternalsVisibleTo("AccUnit.VbeAddIn.Tests") added so TestSuiteManager can be tested.

Tests

  • New NUnit tests: CodeCoverageTrackerTests (3), TestSuiteManagerTests (1). AccUnit.Assertions.Tests 127/127, AccUnit.VbeAddIn.Tests 7/7 (MSBuild + vstest, VS 18).
  • Manual Access check (own visible instance, assemblies loaded by path, no COM registration): Add, Clear(name) and Clear() on a real VBProject behave as expected.

Not verified / notes

  • Delivery of the error message to VBA as COM error (Err.Description) needs the registered VBE add-in and was not tested.
  • Existing behaviour, unchanged: after Add/Clear cycles one extra space remains after the line number in instrumented lines (harmless). Track() still creates unregistered modules without procedure info.

Clear(string codeModuleName = null) threw a NullReferenceException for the default value. Null or empty now clears all modules. Clear(name) also removes the module from the tracker, so the report no longer lists it.
TestSuiteManager.InitTestSuite only showed the exception and returned a null suite, so VBA failed later with a meaningless message. The exception is now logged and rethrown as InvalidOperationException with the original message; UI callers already show exceptions themselves. TestSuiteInitialized is raised only on success.
@josef-poetzl
josef-poetzl merged commit e911c6c into dev Nov 18, 2026
1 check passed
@josef-poetzl
josef-poetzl deleted the feature/suite-error-handling branch November 18, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant