Testing and Validation - danielep71/VBA-Performance_Manager GitHub Wiki

Testing and Validation

This page explains how to test and validate cPerformanceManager after import.

The class exposes multiple timing backends, session-bound validation logic, diagnostics, pause helpers, shared TW control, and structured checkpoint/reporting surfaces. A good validation approach therefore needs more than a single smoke test.

Testing goals

When testing cPerformanceManager, you usually want to answer these questions:

  1. Does the project compile cleanly?
  2. Does the class instantiate correctly?
  3. Do the core timing paths behave sensibly?
  4. Do invalid usage patterns fail or fall back as designed?
  5. Do environment-management features clean up correctly?
  6. Do checkpoint/reporting features behave correctly?

Start with a compile check

Before running any tests, make sure the project compiles:

  1. Open the VBA editor with ALT + F11.
  2. Select the target VBA project.
  3. Use Debug > Compile VBAProject.
  4. Repeat until the compile command is disabled or no errors remain.

Minimal smoke test

Option Explicit

Public Sub Test_Smoke_BasicTiming()

    Dim cPM         As cPerformanceManager
    Dim ElapsedS    As Double

    Set cPM = New cPerformanceManager

    cPM.StartTimer 5
    cPM.Pause 0.05, 1
    ElapsedS = cPM.ElapsedSeconds

    Debug.Print "Smoke elapsed seconds: " & Format$(ElapsedS, "0.000000000")

    cPM.ResetEnvironment
    Set cPM = Nothing

End Sub

Recommended regression layer

The current repo includes a regression harness:

/test/M_cPM_TEST.bas

Use it when you want a broader validation pass after refactoring or release preparation.

The suite now covers:

  • constructor/default state
  • timing methods and session behavior
  • formatted elapsed output
  • strict vs non-strict behavior
  • diagnostics and overhead helpers
  • pause methods
  • shared TW lifecycle
  • ResetEnvironment idempotence
  • checkpoint / reporting behavior

Most important regression additions in the current suite

The latest regression layer includes direct tests for:

  • Checkpoint before StartTimer
  • SetRunLabel before the first checkpoint
  • SetRunLabel rejection after the first checkpoint
  • default checkpoint naming when the supplied name is blank
  • CheckpointCount
  • ReportAsArray
  • ReportAsText
  • ClearCheckpoints
  • StartTimer resetting checkpoint/report state

Recommended validation workflow

  1. compile the project
  2. run the smoke test
  3. run the regression suite
  4. inspect the Immediate Window summary
  5. inspect the dedicated worksheet regression log