Skip to content

Conversation

@inkblot
Copy link

@inkblot inkblot commented Nov 12, 2025

Implements a static assertTrait method that applies a trait to a subject. This allows usage of Trait classes to implement trait-based tests in newer versions of junit and other frameworks.

inkblot added 5 commits July 20, 2025 17:49
- Move the traitor module under a new traitor-project module which aggregates it
- Create a traitor-junit4 module which is also aggregated in traitor-project
- Move all packages in traitor that reference Junit 4 into the traitor-junit4 package
- Remove Junit 4 dependency from traitor module
- Move subject coercion to the one place it has to happen instead of doing it in every case
Trait has an interface method that all trait classes implement. It's not necessary to get the declared `test` method of the specific trait class in use. The abstract interface method is fine. This makes it possible to canonize the Method as a constant and eliminates the need for the `synthesize` method.

Also, if you don't defeat the type system when invoking the TraitFrameworkMethod constructor, you won't get type errors.
- Junit 5 extensions can't create TestDescriptors for a test object the way a Junit 4 runner can
- Allow conventional Junit 5 tests to apply traits via a static assertTrait method
- Relegate the existing example to a "Junit 4" subsection and write an example that uses `assertTrait`.
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.

1 participant