alex salgado
alex salgado

Reputation: 13

Unable to run tests after migrating to junit5

I'm running tests on android using gradle and we're migrating our framework to junit5 to take advantage of some of it's tagging and filtering capabilities. I've created the dependencies in my build.gradle files and I'm able to get it to build and run using the gutter icon in android studio, but I'm unable to run my tests from the command line. I get the following error.

    * What went wrong:
 Execution failed for task ':app:compileTestKotlin'.
 > Could not resolve all files for configuration ':app:testCompileClasspath'.
    > Could not find junit:junit:5.7.0.
      Searched in the following locations:
        - https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.pom
        - https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.jar
        - https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.pom
        - https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.jar
      Required by:
          project :app

Here's my build.gradle at the app level

plugins {
    id 'io.qameta.allure' version '2.8.1' // Latest Plugin Version
    id 'java'
}

allure {
    autoconfigure = true
    version = '2.13.7'  // Latest Allure Version

    useJUnit5 {
        version = '2.13.7' // Latest Allure Version
    }

}

sourceCompatibility = 1.8

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    testImplementation(
            'org.junit.jupiter:junit-jupiter-params:5.7.0',
            'org.junit.jupiter:junit-jupiter-api:5.7.0'
    )
    testRuntimeOnly(
            'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    )
}

test {
    useJUnitPlatform(){
        includeEngines 'junit-jupiter'
    }
}

apply plugin: 'kotlin'

test {
    systemProperty 'platform', project.findProperty('platform')
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
    implementation "io.appium:java-client:7.2.0"
//    implementation 'junit:junit:4.12'
    implementation 'junit:junit:5.7.0'
}

and here's the build.gradle at the project level.

buildscript {
    ext.kotlin_version = '1.3.72'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Upvotes: 1

Views: 864

Answers (1)

johanneslink
johanneslink

Reputation: 5341

The error message says it. implementation 'junit:junit:5.7.0' is a non-existing dependency. Leave it away and it might already work.

Upvotes: 1

Related Questions