Gradle task check if property is defined

后端 未结 3 1023
醉梦人生
醉梦人生 2021-01-17 09:37

I have a gradle task that executes a testng test suite. I want to be able to pass a flag to the task in order to use a special testng xml suite file (or just use the default

3条回答
  •  借酒劲吻你
    2021-01-17 10:10

    if (project.hasProperty('special'))
    

    should do it.

    Note that what you're doing to select a testng suite won't work, AFAIK: the test task doesn't have any test() method. Refer to https://discuss.gradle.org/t/how-to-run-acceptance-tests-with-testng-from-gradle/4107 for a working example:

    test {
        useTestNG {
            suites 'src/main/resources/testng.xml'
        }
    }
    

提交回复
热议问题