Skip to content

fix: quality, correctness and maintenance improvements#92

Open
scolladon wants to merge 26 commits into
salesforce:mainfrom
scolladon:fix/tech-backlog
Open

fix: quality, correctness and maintenance improvements#92
scolladon wants to merge 26 commits into
salesforce:mainfrom
scolladon:fix/tech-backlog

Conversation

@scolladon
Copy link
Copy Markdown
Contributor

@scolladon scolladon commented Mar 17, 2026

Description

A collection of fixes, refactors, and maintenance improvements accumulated in the tech backlog:

Fixes

  • Guard BehaviorManagement.configure against null SpyBehavior and negative times
  • Guard getTypeName() against null and propagate null handling to getType() and TypeMatchable.matches()
  • Use Boolean (capital) consistently on matches() in Argument matchers
  • Restrict Mock.stub to private set to prevent external mutation
  • Fix behaves and behavesOnce documentation

Refactors

  • Extract dispatchBehavior() from MethodSpy.call() for clarity
  • Replace Once subclasses with label constructor parameter
  • Add describeConfigurations() to fix Feature Envy in ConfigurationExceptionBuilder
  • Remove dead constructor and fix ErrorMessageRow field visibility in Expect
  • Remove Argument.ConfigurationException dead code

Tests

  • Add missing @IsTest annotation to MethodSpyTest
  • Fix misleading test name areListsEqual returnsFalse -> returnsTrue
  • Verify exception type in MockTest exception assertion
  • Assert spy was called before exception in FunctionalTest

Docs

  • Add DESIGN.md documenting library architecture and key decisions
  • Add sync-point comments to 1-5 arg overload families
  • Document JSON serialization caching strategy in JSONMatchable
  • Fix parameterized configuration example ordering in README (once/times before general)

Chore

  • Upgrade all API versions to v66.0
  • Add early return to isConfigured() to avoid scanning all behaviors

Motivation and Context

These changes address accumulated technical debt and correctness issues found during code review and from a community-reported documentation bug (wrong assertion order in the parameterized configuration README example).

How Has This Been Tested?

All 138 Apex tests pass (100% pass rate) against a scratch org.

closes #88

This reverts commit d18715049b6dbb8be4476cf3af988f011071db24.
The class was never thrown by the library and existed only as a
deprecated stub. Removes the class and all references in docs.
…havior assertion

- Guard getType() and TypeMatchable.matches() against null typeName to
  prevent NPE after the null guard added to getTypeName()
- Update test assertion to check for 'SpyBehavior' matching the actual
  error message thrown by BehaviorManagement.configure()
- Move 'Test' (general) assertion after 'Test Times' x3 (times) for arg 10,
  since once/times behaviors are always consumed before the general fallback
- Fix behave assertions to use arg -1 (matching the setup) instead of arg 10,
  and reduce from 5 to 4 calls (1 thenBehaveOnce + 3 thenBehave(times))
@scolladon scolladon changed the title fix: tech backlog — quality, correctness and maintenance improvements fix: quality, correctness and maintenance improvements Mar 17, 2026
npm:
- @commitlint/cli: 19.5.0 → 20.5.0
- @commitlint/config-conventional: 19.5.0 → 20.5.0
- @prettier/plugin-xml: 3.4.1 → 3.4.2
- husky: 9.1.6 → 9.1.7
- lint-staged: 15.2.10 → 16.4.0
- prettier: 3.3.3 → 3.8.1
- prettier-plugin-apex: 2.1.5 → 2.2.6
- wireit: 0.14.9 → 0.14.12

GitHub Actions:
- actions/checkout: v4 → v6
- actions/setup-node: v4 → v6
- amannn/action-semantic-pull-request: v5 → v6
Fields are only accessed within the outer Expect class which has access
to private inner class members in Apex, making public unnecessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant