Add an API for custom test method parameter injection
See original GitHub issueI need a way to inject a custom parameter into TestNG’s test methods. The parameter is my own object constructed dynamically at runtime from test method annotations. The custom parameter is not known to TestNG, it’s my own type, e.g.:
@com.mypackage.MyAnnotation("someValue)"
@org.testng.Test
public void test(MyCustomObject val) {
...
}
It looks like right now I cannot do it easily.
Can we add such functionality/SPI? What is the current easiest way to achieve that?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Jersey custom method parameter injection with inbuild injection
Hello I am building an application using dropwizard, that is using jersey 2.16 internally as REST API framework. For ...
Read more >Custom Method Parameter Injection with Jersey
In this article I will explain how to handle custom method parameter injection with Jersey 2. I will first go through some “non-custom” ......
Read more >Dependency Injection and Testing in JUnit - Medium
Parameters of type TestReporter can be injected into methods of test classes annotated with @BeforeEach , @AfterEach , and @Test . The TestReporter...
Read more >Inject Parameters into JUnit Jupiter Unit Tests - Baeldung
Injecting parameters into your test methods could be done using the JUnit 4 API, but it was fairly limited. With JUnit 5, the...
Read more >Minimal APIs quick reference - Microsoft Learn
Custom Binding. There are two ways to customize parameter binding: For route, query, and header binding sources, bind custom types by adding a ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would be very useful I have the same needs
this is true @juherr, i ended doing it this way. But, the only thing that misses is the abilitty to set a default dataProvider for all tests, in my case, my data provider is generics and passes only if there is certain annotations
i think that a combination of the dataProvider and adding the ability to set a default provider or provider class would do the trick and will open a hole new possibilities