sourceSets {
    selenifiedtests {
        java.srcDir 'src/selenified_tests/java'
        resources.srcDir 'src/selenified_tests/resources'
    }
}

dependencies {
    // Selenified, a Coveros application to aid with test needs using Selenium
    // This has a properties file in src/test/resource/selenified_tests.properties
    selenifiedtestsCompile (group: 'com.coveros', name: 'selenified', version: '3.3.0')
}

task selenified(type: Test) {
    testClassesDirs = sourceSets.selenifiedtests.output.classesDirs
    classpath = sourceSets.selenifiedtests.runtimeClasspath
    systemProperties System.getProperties()

    useTestNG() {
        useDefaultListeners = true
        if (System.getProperty("groups.include") != null) {
            includeGroups System.getProperty("groups.include")
        }
        if (System.hasProperty("groups.exclude") != null) {
            excludeGroups System.getProperty("groups.exclude")
        }
    }
    testLogging {
        showStandardStreams = true
        exceptionFormat = 'full'
    }
    options {
        listeners.add("com.coveros.selenified.utilities.Transformer")
        parallel = 'methods'
        threadCount = 1
    }

}

selenified.finalizedBy 'printSelenifiedReportPath'

task('printSelenifiedReportPath') {
    doLast {
        print "\n\n\n"
        println "---------------------------------------------------------------"
        println "A report was generated by the tests."
        println "---------------------------------------------------------------"
        println ""
        println "See build/reports/tests/selenified/report.html"
        println "---------------------------------------------------------------"
        print "\n"
    }
}