Skip to content

feat(test): add PropertyTestHelper trait for property-based tests#419

Merged
kjonescertinia merged 2 commits intomainfrom
feature/411-property-test-helper
Jan 25, 2026
Merged

feat(test): add PropertyTestHelper trait for property-based tests#419
kjonescertinia merged 2 commits intomainfrom
feature/411-property-test-helper

Conversation

@kjonescertinia
Copy link
Contributor

@kjonescertinia kjonescertinia commented Jan 25, 2026

Summary

Add infrastructure for property-based testing and demonstrate with identifier validation tests.

Changes

  1. PropertyTestHelper trait (jvm/src/test/scala/com/nawforce/apexlink/)

    • Combines ScalaCheck's ScalaCheckPropertyChecks with existing TestHelper
    • Uses _root_ prefix to avoid naming conflict with apex-ls's org package
  2. IdentifierPropertyTest (shared/src/test/scala/com/nawforce/pkgforce/names/)

    • 8 property tests verifying identifier validation rules
    • Tests valid identifiers (alphanumeric + underscore patterns)
    • Tests invalid patterns (leading/trailing underscore, leading digit, double underscore, illegal chars)

Property Tests Added

  • valid identifiers are accepted - generates valid patterns, verifies acceptance
  • identifiers starting with underscore are rejected
  • identifiers ending with underscore are rejected
  • identifiers starting with digit are rejected
  • identifiers containing double underscore are rejected
  • identifiers containing illegal characters are rejected
  • single letter identifiers are valid
  • single digit identifiers are invalid

Test plan

  • sbt apexlsJVM/Test/compile succeeds
  • sbt apexlsJVM/testOnly com.nawforce.pkgforce.names.IdentifierPropertyTest - all 8 property tests pass
  • sbt apexlsJVM/test - all 2517 tests pass
  • CI validates build

Closes #411
Closes #412

🤖 Generated with Claude Code

Add infrastructure for property-based testing:
- PropertyTestHelper trait combining ScalaCheck with existing TestHelper
- IdentifierPropertyTest demonstrating property testing on identifier validation

The property tests verify identifier validation rules:
- Valid identifiers (alphanumeric + underscore, proper structure)
- Invalid patterns (leading/trailing underscore, leading digit, double underscore, illegal chars)

Note: Uses _root_ prefix to avoid naming conflict with apex-ls's own org package.

Closes #411
Closes #412
@kjonescertinia kjonescertinia force-pushed the feature/411-property-test-helper branch from 4cc7485 to 923a11a Compare January 25, 2026 09:55
- Add fuzzing test that verifies arbitrary strings are handled
  consistently with the identifier validation spec
- Configure 250 test cases per property for thorough coverage
- Add doc/PropertyTesting.md with guidance on when and how to
  use property-based testing
@kjonescertinia kjonescertinia merged commit fead69b into main Jan 25, 2026
1 check passed
@kjonescertinia kjonescertinia deleted the feature/411-property-test-helper branch January 25, 2026 23:23
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.

Verify property testing setup with trivial test Create PropertyTestHelper base trait

1 participant