jeudi 23 juin 2016

How to define test task that is limited to package?

I have gradle project with tests. Tests are grouped into two packages. I would like to have test task for each package.

My project in gradle:

project(":tests:my-project") {

    ext {
        drivers = ["phantomJs", "chrome"]
    }

    dependencies {
        ...
    }

    apply plugin: "groovy"
    apply from: "gradle/osSpecificDownloads.gradle"

    List suites = ['smoke', 'stress']
    Map testPackages = ['smoke': 'packagename1.*', 'stress': 'packagename2.*']


    drivers.each { driver ->
            task "${driver}Test"(type: Test) {
                reports {
                    html.destination = reporting.file("$name/tests")
                    junitXml.destination = file("$buildDir/test-results/$name")
                }

                outputs.upToDateWhen { false }  

                systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
                systemProperty "geb.env", driver

            }
    }

    chromeTest {
        dependsOn unzipChromeDriver
        def chromedriverFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "chromedriver.exe" : "chromedriver"        systemProperty "webdriver.chrome.driver", new File(unzipChromeDriver.outputs.files.singleFile, chromedriverFilename).absolutePath
    }

    phantomJsTest {
            dependsOn unzipPhantomJs
            def phantomJsFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "bin/phantomjs.exe" : "bin/phantomjs"
            systemProperty "phantomjs.binary.path", new File(unzipPhantomJs.outputs.files.singleFile, phantomJsFilename).absolutePath
    }

    test {
        dependsOn drivers.collect { tasks["${it}Test"] }
        enabled = false
    }
}

Aucun commentaire:

Enregistrer un commentaire