forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroovyTest.groovy
56 lines (46 loc) · 1.66 KB
/
GroovyTest.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package test.groovy
import org.testng.IMethodInstance
import org.testng.IMethodInterceptor
import org.testng.ITestContext
import org.testng.ITestNGListener
import org.testng.TestListenerAdapter
import org.testng.annotations.Test
import org.testng.reporters.JUnitXMLReporter
import test.SimpleBaseTest
import static org.assertj.core.api.Assertions.assertThat
class GroovyTest extends SimpleBaseTest {
@Test
void easyGroovySampleShouldWork() {
def tng = create(EasyJUnitGroovySample)
tng.setJUnit(true)
def adapter = new TestListenerAdapter()
tng.addListener((ITestNGListener)adapter)
tng.run()
assert adapter.failedTests.isEmpty()
assert adapter.skippedTests.isEmpty()
assert adapter.passedTests.size() == 1
}
@Test
void specialNameGroovySampleShouldWork() {
def tng = create(SpecialNameJUnitGroovySample)
tng.setJUnit(true)
def adapter = new TestListenerAdapter()
tng.addListener((ITestNGListener)adapter)
tng.run()
assert adapter.failedTests.isEmpty()
assert adapter.skippedTests.isEmpty()
assert adapter.passedTests.size() == 1
}
@Test(description = "GITHUB-2360")
void groovyInternalMethodsAreSkipped() {
def tng = create Issue2360Sample
def testMethodNames = []
IMethodInterceptor methodInterceptor = { List<IMethodInstance> methods, ITestContext context ->
testMethodNames = methods.collect { it.method.methodName }
methods
}
tng.methodInterceptor = methodInterceptor
tng.run()
assertThat testMethodNames containsExactly "test1", "test2"
}
}