serenity-bdd / serenity-cucumber4-starter

48 stars 73 forks source link

build.gradle adjustments with a provided driver? #11

Open BartVanRaemdonck opened 4 years ago

BartVanRaemdonck commented 4 years ago

When I run my tests in IntelliJ, they work just fine. But when I try to run them with commandline, the webdriver seems not be initialized. I use a provided webdriver that I set in the serenity.conf file. Do I need to make changes to the build.gradle file?

webdriver {

    driver = provided
    provided.type= mydriver
     provided.mydriver = net.persgroep.targetqa.MyCustomDriver
    se.driver.service.pool = false
    thucydides.driver.capabilities = mydriver
 }

My run config in IntelliJ:

Picture 37

My build.gradle file:

defaultTasks 'clean','test','aggregate'

repositories {
    mavenLocal()
    jcenter()
}

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath("net.serenity-bdd:serenity-gradle-plugin:2.0.70")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply from: "$rootDir/gradle/libraries.gradle"

sourceCompatibility = 1.8
targetCompatibility = 1.8

/**
 * This is needed to make sure there are no Cucumber 2 dependencies in the classpath.
 */
configurations.all {
    resolutionStrategy {
        force "io.cucumber:cucumber-core:${cucumberVersion}"
    }
}
dependencies {
    compile libs.logback

    testCompile libs.test.cucumber.java,
            libs.test.cucumber.junit,
            libs.test.serenity.core,
            libs.test.serenity.screenplay,
            libs.test.serenity.junit,
            libs.test.serenity.screenplayWebdriver,
            libs.test.serenity.cucumber,
            libs.test.junit,
            libs.test.assertj

    compile group: 'net.lightbody.bmp', name: 'browsermob-proxy', version: '2.1.5', ext: 'pom'
    compile group: 'net.lightbody.bmp', name: 'browsermob-core', version: '2.1.5'
    compile group: 'de.sstoehr', name: 'har-reader', version: '2.1.4'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}

test {
    testLogging.showStandardStreams = true
    systemProperties System.getProperties()
}

gradle.startParameter.continueOnFailure = true

test.finalizedBy(aggregate)

configurations {
    cucumberRuntime {
        extendsFrom testRuntime
    }
}

task cucumber() {
    dependsOn assemble
    doLast {
        javaexec {
            main = "cucumber.api.cli.Main"
            classpath = configurations.cucumberRuntime
            args = ['--plugin', 'pretty', '--glue net.serenitybdd.cucumber.actors net.persgroep.targetqa.starter.stepdefinitions', 'src/test/java/net/persgroep/targetqa', 'src/test/resources/features']

        }
    }
}

//Ensure the cucumber tests are executed as part of the build. Makes for a very pretty output.
build.dependsOn cucumber