1
votes

When i run my testing.xml as testNG suit its run properly but when run gradle test task it doesn't execute test

testing.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite guice-stage="DEVELOPMENT" name="Default suite">
  <test verbose="2" name="test">
    <classes>
      <class name="com.example.EmpBusinessLogicTest"/>
    </classes>
  </test> <!-- Default test -->
</suite> <!-- Default suite -->

build.gradle

buildscript { ext { springBootVersion = '1.4.1.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } }

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
  baseName = 'demo'
  version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8


repositories {
  mavenCentral()
}


dependencies {
  compile('org.springframework.boot:spring-boot-starter-web')
  testCompile('org.springframework.boot:spring-boot-starter-test')
  compile('org.testng:testng:6.9.10')

}

test {
    useTestNG() 
    {        
        suites 'src/main/resources/testing.xml'

    }
}

can anyone help me to execute gradle test task ?

1

1 Answers

1
votes

As option you can generate xml directly in gradle in test task, it works fine in our project

useTestNG() {
    suiteXmlBuilder().suite(name: 'Default suite') {
        test(name : 'test') {
            classes('') {
                'class'(name: 'com.example.EmpBusinessLogicTest')
            }
        }
    }
}

To execute this test task e.g. with Jenkins you will need to pass system properties to it:

systemProperties System.getProperties()
systemProperty 'user.dir', project.projectDir