A compile test is a software test whose expected outcome is successful compilation of generated or written code. It provides an early check that macro output is valid, even before runtime behavior is verified. section 6.4.1
Use a compile test to:
- Exercise a minimal generated API, such as constructing a builder and calling build. section 6.4.1
- Turn compiler diagnostics into implementation feedback when generated identifiers, return types, or quoted variables are wrong. section 6.4.1
- Verify that type-state constraints reject incomplete builder calls by omitting a required property and checking the resulting error. section 8.5.2
Testing a generated builder
A black-box test derives Builder for an empty struct, calls ExampleStructNoFields::builder().build(), and assigns the result to the expected type. For a type-state builder, a test can omit the final property; compilation then fails because build exists only for the final builder state.
