Skip to content

Commit a1897e0

Browse files
committed
Convert to JUnit5
1 parent 85a9f8e commit a1897e0

File tree

1,225 files changed

+9085
-3972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,225 files changed

+9085
-3972
lines changed

src/spec/test/BaseScriptSpecTest.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import groovy.test.GroovyTestCase
19+
2020
import groovy.transform.CompileStatic
2121

22+
import static groovy.test.GroovyAssert.assertScript
23+
2224
@CompileStatic
23-
class BaseScriptSpecTest extends GroovyTestCase {
25+
class BaseScriptSpecTest {
2426
void testSimpleScript() {
2527
def script = '''
2628
// tag::simple_script[]

src/spec/test/ClassDesignASTTransformsTest.groovy

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import groovy.test.GroovyTestCase
2019

21-
class ClassDesignASTTransformsTest extends GroovyTestCase {
2220

21+
import org.junit.jupiter.api.Test
22+
23+
import static groovy.test.GroovyAssert.assertScript
24+
25+
class ClassDesignASTTransformsTest {
26+
27+
@Test
2328
void testDelegateTransformation() {
2429
assertScript '''
2530
// tag::delegating_class[]
@@ -269,6 +274,7 @@ d.task$() //passes
269274
'''
270275
}
271276

277+
@Test
272278
void testImmutable() {
273279
assertScript '''
274280
// tag::immutable_simple[]
@@ -369,6 +375,7 @@ try {
369375
'''
370376
}
371377

378+
@Test
372379
void testMemoized() {
373380
assertScript '''
374381
import groovy.transform.Memoized
@@ -407,6 +414,7 @@ assert x!=z
407414
'''
408415
}
409416

417+
@Test
410418
void testSingleton() {
411419
assertScript '''
412420
// tag::singleton_simple[]
@@ -451,6 +459,7 @@ assert GreetingService.instance.greeting('Bob') == 'Hello, Bob!'
451459
'''
452460
}
453461

462+
@Test
454463
void testTailRecursive() {
455464
assertScript '''
456465
// tag::tailrecursive[]

src/spec/test/ClassTest.groovy

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
* under the License.
1818
*/
1919

20-
import groovy.test.GroovyTestCase
2120

22-
final class ClassTest extends GroovyTestCase {
21+
final class ClassTest {
2322

2423
void testClassDefinition() {
2524
assertScript '''
@@ -230,7 +229,7 @@ final class ClassTest extends GroovyTestCase {
230229
}
231230
// end::protected_forbidden[]
232231
'''
233-
assert err.contains("The method 'greet' must be public as it is declared abstract in interface 'Greeter'")
232+
assert err.message.contains("The method 'greet' must be public as it is declared abstract in interface 'Greeter'")
234233
}
235234

236235
void testFields() {
@@ -730,7 +729,7 @@ import java.lang.annotation.Retention
730729
class Evil {}
731730
Evil
732731
'''
733-
assert err =~ /Attribute 'value' should have type 'java.lang.String'; but found type 'int' in @Foo/
732+
assert err.message =~ /Attribute 'value' should have type 'java.lang.String'; but found type 'int' in @Foo/
734733
}
735734

736735
void testCustomProcessor() {
@@ -760,6 +759,9 @@ import java.lang.annotation.Retention
760759
import org.codehaus.groovy.ast.expr.PropertyExpression
761760
import org.codehaus.groovy.control.SourceUnit
762761
import org.codehaus.groovy.transform.AnnotationCollectorTransform
762+
import org.junit.jupiter.api.Test
763+
import org.junit.jupiter.api.Timeout
764+
import static groovy.test.GroovyAssert.*
763765
764766
// tag::compiledynamic_def_fixed[]
765767
@AnnotationCollector(processor = "org.codehaus.groovy.transform.CompileDynamicProcessor")

src/spec/test/CloningASTTransformsTest.groovy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import groovy.test.GroovyTestCase
21

32
/*
43
* Licensed to the Apache Software Foundation (ASF) under one
@@ -18,7 +17,13 @@ import groovy.test.GroovyTestCase
1817
* specific language governing permissions and limitations
1918
* under the License.
2019
*/
21-
class CloningASTTransformsTest extends GroovyTestCase {
20+
21+
import org.junit.jupiter.api.Test
22+
23+
import static groovy.test.GroovyAssert.assertScript
24+
25+
class CloningASTTransformsTest {
26+
@Test
2227
void testAutoCloneAnnotation() {
2328
assertScript '''
2429
// tag::example_autoclone[]
@@ -59,6 +64,7 @@ assert !(book.authors.is(clone.authors))
5964
'''
6065
}
6166

67+
@Test
6268
void testAutoCloneAnnotationWithExclude() {
6369
assertScript '''
6470
// tag::example_autoclone_excludes[]
@@ -82,6 +88,7 @@ assert clone.publicationDate==book.publicationDate
8288
'''
8389
}
8490

91+
@Test
8592
void testAutoCloneAnnotationWithIncludeFields() {
8693
assertScript '''
8794
// tag::example_autoclone_includeFields[]
@@ -105,6 +112,7 @@ assert clone.publicationDate==book.publicationDate
105112
'''
106113
}
107114

115+
@Test
108116
void testAutoExternalize() {
109117
assertScript '''
110118
// tag::example_autoext[]
@@ -168,6 +176,7 @@ assert book.price == 1.5
168176
'''
169177
}
170178

179+
@Test
171180
void testAutoExternalizeWithExcludes() {
172181
assertScript '''
173182
// tag::example_autoext_excludes[]
@@ -209,6 +218,7 @@ assert book.title == 'Auto externalization for dummies'
209218
assert book.price == 0 // because price is excluded
210219
'''
211220
}
221+
@Test
212222
void testAutoExternalizeWithIncludeFields() {
213223
assertScript '''
214224
// tag::example_autoext_includeFields[]

src/spec/test/ClosuresSpecTest.groovy

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import groovy.test.GroovyTestCase
1+
import org.junit.jupiter.api.Test
2+
3+
import static groovy.test.GroovyAssert.assertScript
24

35
/*
46
* Licensed to the Apache Software Foundation (ASF) under one
@@ -18,9 +20,10 @@ import groovy.test.GroovyTestCase
1820
* specific language governing permissions and limitations
1921
* under the License.
2022
*/
21-
class ClosuresSpecTest extends GroovyTestCase {
23+
class ClosuresSpecTest {
2224
static void sink(Closure cl) {}
2325

26+
@Test
2427
void testClosureSyntax() {
2528
sink
2629
// tag::closure_syntax_1[]
@@ -61,6 +64,7 @@ class ClosuresSpecTest extends GroovyTestCase {
6164
// end::closure_syntax_6[]
6265
}
6366

67+
@Test
6468
void testAssignClosureToAVariable() {
6569
// tag::closure_is_an_instance_of_Closure[]
6670
def listener = { e -> println "Clicked on $e.source" } // <1>
@@ -72,6 +76,7 @@ class ClosuresSpecTest extends GroovyTestCase {
7276
// end::closure_is_an_instance_of_Closure[]
7377
}
7478

79+
@Test
7580
void testCallClosure() {
7681
// tag::closure_call_1[]
7782
def code = { 123 }
@@ -94,6 +99,7 @@ class ClosuresSpecTest extends GroovyTestCase {
9499
// end::closure_call_2[]
95100
}
96101

102+
@Test
97103
void testClosureParameters() {
98104
// tag::closure_param_declaration[]
99105
def closureWithOneArg = { str -> str.toUpperCase() }
@@ -116,6 +122,7 @@ class ClosuresSpecTest extends GroovyTestCase {
116122
// end::closure_param_declaration[]
117123
}
118124

125+
@Test
119126
void testImplicitIt() {
120127
assertScript '''
121128
// tag::implicit_it[]
@@ -146,6 +153,7 @@ class ClosuresSpecTest extends GroovyTestCase {
146153
'''
147154
}
148155

156+
@Test
149157
void testClosureVargs() {
150158
// tag::closure_vargs[]
151159
def concat1 = { String... args -> args.join('') } // <1>
@@ -161,6 +169,7 @@ class ClosuresSpecTest extends GroovyTestCase {
161169

162170
}
163171

172+
@Test
164173
void testThisObject() {
165174
assertScript '''
166175
// tag::closure_this[]
@@ -217,6 +226,7 @@ class ClosuresSpecTest extends GroovyTestCase {
217226
'''
218227
}
219228

229+
@Test
220230
void testOwner() {
221231
assertScript '''
222232
// tag::closure_owner[]
@@ -253,6 +263,7 @@ class ClosuresSpecTest extends GroovyTestCase {
253263
'''
254264
}
255265

266+
@Test
256267
void testClosureDelegate() {
257268
assertScript '''
258269
// tag::delegate_is_owner[]
@@ -306,6 +317,7 @@ class ClosuresSpecTest extends GroovyTestCase {
306317
'''
307318
}
308319

320+
@Test
309321
void testDelegationStrategy() {
310322
assertScript '''
311323
// tag::delegation_strategy_intro[]
@@ -320,6 +332,7 @@ class ClosuresSpecTest extends GroovyTestCase {
320332
'''
321333
}
322334

335+
@Test
323336
void testOwnerFirst() {
324337
assertScript '''
325338
// tag::closure_owner_first[]
@@ -349,6 +362,7 @@ class ClosuresSpecTest extends GroovyTestCase {
349362
'''
350363
}
351364

365+
@Test
352366
void testDelegateOnly() {
353367
assertScript '''
354368
// tag::delegate_only[]
@@ -383,6 +397,7 @@ class ClosuresSpecTest extends GroovyTestCase {
383397
'''
384398
}
385399

400+
@Test
386401
void testDelegateOnlyPropertyMissing() {
387402
assertScript '''
388403
// tag::delegate_only_prop_missing[]
@@ -408,6 +423,7 @@ class ClosuresSpecTest extends GroovyTestCase {
408423
'''
409424
}
410425

426+
@Test
411427
void testGStringEager() {
412428
// tag::gstring_eager_intro[]
413429
def x = 1
@@ -424,6 +440,7 @@ class ClosuresSpecTest extends GroovyTestCase {
424440
assert gs == 'x = 1'
425441
}
426442

443+
@Test
427444
void testGStringLazy() {
428445
// tag::gstring_lazy[]
429446
def x = 1
@@ -435,6 +452,7 @@ class ClosuresSpecTest extends GroovyTestCase {
435452
// end::gstring_lazy[]
436453
}
437454

455+
@Test
438456
void testGStringWithMutation() {
439457
assertScript '''
440458
// tag::gstring_mutation[]
@@ -455,6 +473,7 @@ class ClosuresSpecTest extends GroovyTestCase {
455473
'''
456474
}
457475

476+
@Test
458477
void testGStringWithoutMutation() {
459478
assertScript '''
460479
// tag::gstring_no_mutation[]
@@ -474,6 +493,7 @@ class ClosuresSpecTest extends GroovyTestCase {
474493
'''
475494
}
476495

496+
@Test
477497
void testLeftCurry() {
478498
// tag::left_curry[]
479499
def nCopies = { int n, String str -> str*n } // <1>
@@ -483,6 +503,7 @@ class ClosuresSpecTest extends GroovyTestCase {
483503
// end::left_curry[]
484504
}
485505

506+
@Test
486507
void testRightCurry() {
487508
// tag::right_curry[]
488509
def nCopies = { int n, String str -> str*n } // <1>
@@ -492,6 +513,7 @@ class ClosuresSpecTest extends GroovyTestCase {
492513
// end::right_curry[]
493514
}
494515

516+
@Test
495517
void testNCurry() {
496518
// tag::ncurry[]
497519
def volume = { double l, double w, double h -> l*w*h } // <1>
@@ -502,6 +524,7 @@ class ClosuresSpecTest extends GroovyTestCase {
502524
// end::ncurry[]
503525
}
504526

527+
@Test
505528
void testMemoize() {
506529
// tag::naive_fib[]
507530
def fib
@@ -514,6 +537,7 @@ class ClosuresSpecTest extends GroovyTestCase {
514537
// end::memoized_fib[]
515538
}
516539

540+
@Test
517541
void testComposition() {
518542
// tag::closure_composition[]
519543
def plus2 = { it + 2 }
@@ -533,6 +557,7 @@ class ClosuresSpecTest extends GroovyTestCase {
533557

534558
}
535559

560+
@Test
536561
void testTrampoline() {
537562
// tag::trampoline[]
538563
def factorial

0 commit comments

Comments
 (0)