question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an API for custom test method parameter injection

See original GitHub issue

I 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:open
  • Created 9 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
g13013commented, Nov 8, 2016

Would be very useful I have the same needs

1reaction
g13013commented, Nov 9, 2016

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found