Skip to content

[Maintenance] Add actor and expansion error tests for @_MockedProperty macro #149

Description

@graycampbell

What area needs maintenance?

@_MockedProperty macro test coverage in Tests/MockingMacrosTests/Macros/MockedPropertyMacro/.

Why is this improvement needed?

When subscript support was added in PR #148, @_MockedSubscript gained actor expansion tests (MockedSubscript_ActorTests.swift) verifying nonisolated modifiers are generated correctly when isMockAnActor: true, and expansion error tests (MockedSubscriptMacro_ExpansionErrorTests.swift) verifying the macro emits a diagnostic when applied to a non-subscript declaration. @_MockedProperty has neither. The existing assertMockedProperty helper also hard-codes isMockAnActor: false, so actor scenarios cannot be tested at all.

Proposed solution

  1. Add an isMockAnActor: Bool = false parameter to assertMockedProperty in Tests/MockingMacrosTests/Macros/MockedPropertyMacro/TestHelpers/AssertMockedProperty.swift
  2. Add Tests/MockingMacrosTests/Macros/MockedPropertyMacro/MockedProperty_ActorTests.swift testing read-only and read-write property expansion in actor mocks
  3. Add Tests/MockingMacrosTests/Macros/MockedPropertyMacro/MockedPropertyMacro_ExpansionErrorTests.swift testing the error when applied to a non-property declaration

Metadata

Metadata

Assignees

No one assigned

    Labels

    testingChanges related to testing

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions