Run a specific TestNG XML test suite with Gradle from command line?

后端 未结 3 1218
囚心锁ツ
囚心锁ツ 2021-02-11 03:10

I am using Gradle with TestNG. I have this build.gradle:

useTestNG() {
        useDefaultListeners = true
        suites \"src/test/resources/tests1.xml\"
               


        
3条回答
  •  忘了有多久
    2021-02-11 03:53

    you can specify variable let say suiteFile with default value and use it in testNG section. For example:

    ext{
    
        set suiteFile, default is 'testrun_config.xml'
        if (!project.hasProperty('suiteFile')) {
            suiteFile = 'testrun_config.xml'
        }
    }
    
    test {
        useTestNG() {
            dependsOn cleanTest
            useDefaultListeners = true
            suites "src/test/resources/"+suiteFile
    
        }
    } 
    

    Refer qaf gradle build file

    If you want to pass through command line

    gradlew test -PsuiteFile=test.xml
    

提交回复
热议问题