Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Junit 5 - No ParameterResolver registered for parameter

I can write up and execute Selenium script without any special test framework but I wanted to use Junit 5 (because we have dependency with other tools) and I have never seen such error org.junit.jupiter.api.extension.ParameterResolutionException while working with Junit 4.

Currently it's Junit 5 and I googled it to get some sort of idea but can not resolve the issue.

Test script using JUnit 5, Eclipse 4.8 and Selenium:

import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement;  public  class loginTest  {     public  WebDriver driver = null;      public loginTest(WebDriver driver) {         this.driver=driver;     }      @BeforeEach     public void setUp() throws Exception {         driver.get("google.com");         System.out.println("Page title is: " + driver.getTitle());     }      @Test     public void test() {         // some action here I have in original script         System.out.println("Page title is: " + driver.getTitle());     }      @AfterEach     public void tearDown() throws Exception {         driver.quit();     } } 

Stack trace:

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.openqa.selenium.WebDriver arg0] in executable [public login.loginTest(org.openqa.selenium.WebDriver)]. at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:191)

like image 585
Mike ASP Avatar asked Aug 15 '18 23:08

Mike ASP


2 Answers

I had both @Test and @ParameterizedTest annotating the same method. I removed the former.

like image 110
Will Avatar answered Sep 29 '22 03:09

Will


This error appears when you try to use both @Test and @ParameterizedTest in the same test class. Removing @Test annotation will resolve the issue.

like image 31
muhin Avatar answered Sep 29 '22 04:09

muhin