来自testng selenium的Gradle测试

时间:2016-05-05 16:29:26

标签: selenium gradle testng

我有一个gradle脚本,应该从命令行运行testng xml文件。但是每当我尝试运行时都使用grald测试,我得到以下输出。即使没有打开浏览器也没有测试运行

C:\Users\Steve\Documents\Projects\automation>gradle test
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE

BUILD SUCCESSFUL

我的gradle脚本如下

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

group = 'automation'
version = '1.1-SNAPSHOT'

description = ""

repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'2.52.0'
    compile group: 'org.uncommons', name: 'reportng', version:'1.1.4'
    compile group: 'org.apache.velocity', name: 'velocity', version:'1.7'
    compile group: 'com.google.inject', name: 'guice', version:'4.0'
    testCompile group: 'junit', name: 'junit', version:'3.8.1'
    testCompile group: 'org.testng', name: 'testng', version:'6.9.4'
}
test{
    useTestNG{

    include '/src/test/resources/BasicTestXML/**'}
}

2 个答案:

答案 0 :(得分:0)

include用于包含(或不包含)测试类: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

你在寻找的是什么 suites。 请参阅the TestNG build file中的示例。

答案 1 :(得分:0)

找到解决方法如何运行它们并选择要运行的

test{

    useTestNG() {
        suites "src/test/resources/BasicTestXML/LoginTest.xml"
    }
}

通过这种方式,您可以选择运行哪个xml文件。如果你想要一个额外的运行只需添加一个额外的套件线。

相关问题