Junit 5 - No ParameterResolver registered for parameter
As Marc Philipp mentioned in his comment, you need to ensure that JUnit Jupiter can instantiate your test class.
For your particular scenario, you'll need to remove your custom constructor that accepts a WebDriver
.
Then you have two options:
- Create the
WebDriver
on your own -- for example, in an@BeforeAll
or@BeforeEach
method. - Use an extension such as Selenium Jupiter to help manage the
WebDriver
for you.
Junit5 call methos with parameter but receive error: No ParameterResolver registered for parameter
It is because you specify some arguments in your test method and you need to configure it in order to tell JUnit how to resolve the value for those parameters.
For the arguments that are provided by JUnit such as TestInfo
, TestReport
or RepetitionInfo
, it will be automatically be resolved without any extra configuration.
But for other arguments such as the orderId in your case ,you have to change your test case to a @ParameterizedTest
such that you can use @ValueSource
/ @EnumSource
/ @MethodSource
/ @CsvSource
or @ArgumentsSource
etc. to define the actual value for the orderId (see this for details).
So change your test case to the following should solve your problem :
@ParameterizedTest
@ValueSource(strings = {"order1" , "order2" , "order3"})
@Order(1)
void test1(String myOrderId , TestInfo testInfo) {
log.info("Start test case: " + testInfo.getDisplayName());
if (myOrderId != null)
log.info("MyOrderId is: " + myOrderId);
}
One thing that need to pay attention is that the arguments that are resolved by argument sources (i.e @ValueSource
) should be come first in the argument list. (see this).
Pact consumer junit5 - No ParameterResolver registered for parameter [au.com.dius.pact.consumer.MockServer mockServer]
The version of @PactTestFor
method still needs to use version 3.
@Test
@PactTestFor(providerName = PACT_PROVIDER, port = "8080", pactVersion = PactSpecVersion.V3)
No ParameterResolver registered for parameter in BeforeAll method
Solved. Changed TestContext to VertxTestContext and used its methods.
Also i deleted Async async = context.async()
Related Topics
How to Upload a File and Json Data in Postman
How to Split a String Between Letters and Digits (Or Between Digits and Letters)
How to Sort Date in Descending Order Using Comparator
Null Pointer on an Autowired Bean Which Is Not Mocked by Mockito
Error Says It's Dividing by Zero While It's Not Initialised as Zero
Use String.Split() With Multiple Delimiters
How to Write a User Input Based Constructor
How to Pass a List and a Separate String Using @Requestbody in Springboot
Wait Until All Threads Finish Their Work in Java
How to Format a String Number to Have Commas and Round
Multipartexception: Current Request Is Not a Multipart Request
What Happens When Base and Derived Classes Each Have Variables With the Same Name
How to Find Distinct Rows With Field in List Using JPA and Spring
Java: How to Print Array Without Square Brackets and Commas
How to Do a Limit Query in Jpql or Hql
How to Use Jackson to Deserialise an Array of Objects
How to Get the Autoincremented Id When I Insert a Record in a Table Via Jdbctemplate