Skip to content

v0.18.3: Enhanced Panic Testing and Build Improvements

Latest
Compare
Choose a tag to compare
@amery amery released this 07 Sep 19:44
fae8f6b

Release v0.18.3

🎯 Highlights

This release enhances the AssertPanic testing utility with intelligent type-aware matching capabilities and includes significant build system improvements for better coverage collection and reporting.

✨ Features

Enhanced Panic Testing

  • Type-aware panic validation: AssertPanic now provides different matching strategies based on the expected type.
    • nil: Accepts any panic (most common use case).
    • error: Uses errors.Is for error chain matching.
    • string: Performs substring matching for more resilient tests.
    • Recovered: Direct comparison without unwrapping.
    • Other types: Exact equality check with automatic Recovered unwrapping.
  • Improved logging: Panic assertions now include clear context in their log messages.
  • 100% test coverage: The entire testing.go file now has complete test coverage.

Build System Enhancements

  • Enhanced coverage collection: New HTML and text report generation with .tmp/coverage/ directory structure.
  • Improved Codecov integration: Better monorepo support with module-specific coverage targets.
  • Go 1.25 support: Added as the default version in CI/CD pipelines.

🔧 Improvements

Development Experience

  • Enhanced .editorconfig with comprehensive file type support.
  • Improved .gitignore with additional patterns for better repository hygiene.
  • Reorganised Makefile variable definitions for better maintainability.
  • Updated GitHub Actions to latest versions (setup-go v6, setup-node v5).

Code Quality

  • Refactored doAssertPanic helpers for cleaner implementation.
  • Simplified panic validation logic by removing the report flag.
  • Consistent use of the ok := test() pattern throughout.
  • Field-aligned test structures for memory efficiency.

⚠️ Breaking Changes

  • AssertPanic string matching: String expectations now use substring matching instead of exact equality.

    // Previously would fail, now passes:
    AssertPanic(t, func() { panic("unexpected error occurred") }, "error", "test")
  • AssertPanic error matching: Error expectations now use errors.Is semantics for chain matching.

    // Now matches wrapped errors:
    AssertPanic(t, func() { panic(fmt.Errorf("wrapped: %w", io.EOF)) }, io.EOF, "test")

📊 Statistics

  • Files changed: 16
  • Insertions: 339 lines
  • Deletions: 139 lines
  • Test coverage: 97.3% overall, 100% for testing.go

🤝 Contributors

📦 Dependencies

  • Updated actions/setup-go to v6.
  • Updated actions/setup-node to v5.

🔗 Links


This release focuses on making panic testing more intuitive and resilient whilst maintaining backward compatibility for most use cases. The enhanced type-aware matching aligns with developer expectations and reduces test brittleness.