testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

Add a way for 3rd party to intercept method param injection #1164

Open juherr opened 8 years ago

juherr commented 8 years ago

From https://github.com/jmockit/jmockit1/issues/337

It should work with and without dataprovider.

@rliesenfeld Any wishes on a future provided API?

@nitinverma is open to participate to the integration as he already made good job on param injection.

rliesenfeld commented 8 years ago

I think the brand new JUnit 5 extension model can be a good source of inspiration. The only thing missing in JUnit 5 is a way for a 3rd-party library to automatically register those extensions, without users having to manually add "@ExtendWith" annotations to their test classes.

TestNG already has a set of extension interfaces (IExecutionListener, for example, which JMockit implements), but none similar to JUnit's ParameterResolver interface. I imagine something like this could be added.

nitinverma commented 8 years ago

I would like to propose we should think not just about method argument injection but other augmentations/extensions that may be possible to a testing framework.

Following is a preliminary idea on generically supporting/exposing integrations:

Metaphor:

TestNG is a mothership and other products are pods. Pods dock in the mothership and offer bunch of features. Features get coupled or coupling waits of another features (via same pod or another) or rejected as is retracted. Once the couplings are in place mothership can engage or disengage to carryout proper functioning and course correction.

Above is just a rough outline I hope gets enriched via discussion.

juherr commented 8 years ago

I like the vision but it can be done by steps and method argument injection is the perfect candidate for the first step.

And currently, listeners are a good way for 3rd party extensions.