add example how to run TestNG test with Gradle on Groovy code

This commit is contained in:
Juraj Michalek
2014-05-19 08:01:19 +02:00
parent f2ebeb16d7
commit 72f5baa4fd
4 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
apply plugin: 'groovy'
dependencies {
compile gradleApi()
}
test {
useTestNG()
}

View File

@@ -0,0 +1,8 @@
package com.ysoft.training
class Calculator {
int add(x, y) {
return x+y
}
}

View File

@@ -0,0 +1,13 @@
import com.ysoft.training.Calculator
import org.testng.annotations.Test
import org.testng.Assert
class CalculatorTest {
@Test
void stitchInTimeSavesNine() {
def calculator = new Calculator()
Assert.assertEquals(calculator.add(4,5), 9)
}
}

View File

@@ -171,3 +171,14 @@ It is possible to stop build by throwing exception.
gradle workingTask
gradle failingTask
## 17-testng-groovy
Example combines usage of TestNG for testing and tests written in Groovy.
It is necessary to declare 'useTestNG()' in test configuration.
Otherwise tests won't be executed.
gradle test
Reports are stored in build/reports/tests/index.html