mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-04-26 10:18:50 +02:00
add example how to run TestNG test with Gradle on Groovy code
This commit is contained in:
9
17-testng-groovy/build.gradle
Normal file
9
17-testng-groovy/build.gradle
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
apply plugin: 'groovy'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile gradleApi()
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useTestNG()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.ysoft.training
|
||||||
|
|
||||||
|
class Calculator {
|
||||||
|
int add(x, y) {
|
||||||
|
return x+y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
11
README.md
11
README.md
@@ -171,3 +171,14 @@ It is possible to stop build by throwing exception.
|
|||||||
|
|
||||||
gradle workingTask
|
gradle workingTask
|
||||||
gradle failingTask
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user