@RunWith does not work because the import of junit is not recognized

Viewed 54

I am using Vscode, Gradle version 7.5.1 with Junit 4.13.2

This is my build.gradle.

    plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
}

    sourceCompatibility = 15

    repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

    dependencies {
    

    
    implementation 'com.google.guava:guava:30.1.1-jre'
    
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.4.0'
    implementation group: 'io.cucumber', name: 'cucumber-java', version: '7.6.0'
    
    testImplementation group: 'io.cucumber', name: 'cucumber-junit', version: '7.6.0'

    // this is the dependency that does not work 
    testImplementation group: 'junit', name: 'junit', version: '4.13.2'
  
}

This is the java file.

The problem is in this part.

This import is not recognized: "import org.junit.runner.RunWith;" that problem causes @RunWith not to work

    package runner;
    import org.junit.runner.RunWith; // This line does not work
    @RunWith(Cucumber.class) //This line does not work

This is the error : The import org.junit cannot be resolved

0 Answers
Related