Description
I'm trying to update CDI-Unit to support JUnit 5, specifically CDI-Unit's ProducerConfig
feature for JUnit 4 which uses annotations on the test method to help configure the deployment payload for Weld. Weld is then used to construct test instances. This can almost be replicated in JUnit 5, by implementing a TestInstanceFactory
. (Obviously this won't be compatible with Lifecycle.PER_CLASS
, because the instances must allow for per-method configuration.)
The problem is, when TestInstanceFactory.createTestInstance()
is called, extensionContext.getTestMethod()
always returns Optional.empty()
, even when using Lifecycle.PER_METHOD
.
If the TestInstanceFactory
were to receive the test Method, when using Lifecycle.PER_METHOD
, it would be possible to use annotations from the test method to control test instance creation, thus allowing features like ProducerConfig
to be created.