Laurent Duvergé
Laurent Duvergé

Reputation: 559

In a junit5 test class can weldinitiator config be specific for each test method?

In a junit5 test class can weldinitiator config be specific (i.e different behaviour of mocks) for each method of the test class? Because I could only do and I only found one weldinitiator config for the whole test class but never for test methods specifically. Thank you.

Upvotes: 0

Views: 310

Answers (1)

Siliarus
Siliarus

Reputation: 6753

No, you cannot. WeldInitiator effectively provides a configuration for JUnit 5 extension that weld-junit uses to bootstrap itself and it is class-wide.

If you have an idea (pseudo code) of how this could look like, please create a GitHub issue on the project. Personally, I cannot imagine a way in which it wouldn't introduce more mess then order into testing. It is true that you can boot Weld on a per-test-method basis (in fact I think that's the basic mode), so in theory it could exist, but in the same time you can "workaround" this by creating an abstract class as a parent with your test logic and then as many subclasses as you like, each of which will have its own configured WeldInitiator - that should achieve exactly the same goal.

Upvotes: 1

Related Questions