Skip to content

Commit 044fbcd

Browse files
committed
Fix Kotlin includes and examples
Signed-off-by: Danil Pavlov <danil.pavlov@jetbrains.com>
1 parent ddf7f78 commit 044fbcd

8 files changed

Lines changed: 99 additions & 134 deletions

File tree

documentation/modules/ROOT/pages/writing-tests/parameterized-classes-and-tests.adoc

Lines changed: 44 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=simple_MethodSourc
634634
Kotlin::
635635
+
636636
--
637-
[source,kotlin,indent=0]
637+
[source,kotlin]
638638
----
639-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=simple_MethodSource_example]
639+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=simple_MethodSource_example,indent=0]
640640
641-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=stringProvider]
641+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=stringProvider,indent=0]
642642
----
643643
--
644644
====
@@ -662,14 +662,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=simple_MethodSourc
662662
Kotlin::
663663
+
664664
--
665-
[source,kotlin,indent=0]
666-
----
667-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=simple_MethodSource_without_value_example]
665+
[source,kotlin]
668666
----
667+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=simple_MethodSource_without_value_example,indent=0]
669668
670-
[source,kotlin,indent=0]
671-
----
672-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=testWithDefaultLocalMethodSource_provider]
669+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=testWithDefaultLocalMethodSource_provider,indent=0]
673670
----
674671
--
675672
====
@@ -691,9 +688,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=primitive_MethodSo
691688
Kotlin::
692689
+
693690
--
694-
[source,kotlin,indent=0]
691+
[source,kotlin]
695692
----
696-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[lines=189..193;567]
693+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=primitive_MethodSource_example,indent=0]
694+
695+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=range,indent=0]
697696
----
698697
--
699698
====
@@ -719,9 +718,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=multi_arg_MethodSo
719718
Kotlin::
720719
+
721720
--
722-
[source,kotlin,indent=0]
721+
[source,kotlin]
723722
----
724-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=multi_arg_MethodSource_example;stringIntAndListProvider]
723+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=multi_arg_MethodSource_example,indent=0]
724+
725+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=stringIntAndListProvider,indent=0]
725726
----
726727
--
727728
====
@@ -775,9 +776,11 @@ include::example$java/example/MethodSourceParameterResolutionDemo.java[tags=para
775776
Kotlin::
776777
+
777778
--
778-
[source,kotlin,indent=0]
779+
[source,kotlin]
779780
----
780-
include::example$kotlin/example/kotlin/MethodSourceParameterResolutionDemo.kt[tags=parameter_resolution_MethodSource_example]
781+
include::example$kotlin/example/kotlin/MethodSourceParameterResolutionDemo.kt[tags=parameter_resolution_MethodSource_example,indent=0]
782+
783+
include::example$kotlin/example/kotlin/MethodSourceParameterResolutionDemo.kt[tags=parameter_resolution_factory_MethodSource_example,indent=0]
781784
----
782785
--
783786
====
@@ -847,14 +850,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=default_field_Fiel
847850
Kotlin::
848851
+
849852
--
850-
[source,kotlin,indent=0]
851-
----
852-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=default_field_FieldSource_example]
853+
[source,kotlin]
853854
----
855+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=default_field_FieldSource_example,indent=0]
854856
855-
[source,kotlin,indent=0]
856-
----
857-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=arrayOfFruits]
857+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tags=arrayOfFruits,indent=0]
858858
----
859859
--
860860
====
@@ -877,14 +877,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=explicit_field_Fie
877877
Kotlin::
878878
+
879879
--
880-
[source,kotlin,indent=0]
881-
----
882-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=explicit_field_FieldSource_example]
880+
[source,kotlin]
883881
----
882+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=explicit_field_FieldSource_example,indent=0]
884883
885-
[source,kotlin,indent=0]
886-
----
887-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=listOfFruits]
884+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=listOfFruits,indent=0]
888885
----
889886
--
890887
====
@@ -909,19 +906,13 @@ include::example$java/example/ParameterizedTestDemo.java[tags=multiple_fields_Fi
909906
Kotlin::
910907
+
911908
--
912-
[source,kotlin,indent=0]
913-
----
914-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=multiple_fields_FieldSource_example]
909+
[source,kotlin]
915910
----
911+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=multiple_fields_FieldSource_example,indent=0]
916912
917-
[source,kotlin,indent=0]
918-
----
919-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=listOfFruits]
920-
----
913+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=listOfFruits,indent=0]
921914
922-
[source,kotlin,indent=0]
923-
----
924-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=additionalFruits]
915+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=additionalFruits,indent=0]
925916
----
926917
--
927918
====
@@ -947,14 +938,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=named_arguments_Fi
947938
Kotlin::
948939
+
949940
--
950-
[source,kotlin,indent=0]
951-
----
952-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_arguments_FieldSource_example]
941+
[source,kotlin]
953942
----
943+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_arguments_FieldSource_example,indent=0]
954944
955-
[source,kotlin,indent=0]
956-
----
957-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=namedArgumentsSupplier]
945+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=namedArgumentsSupplier,indent=0]
958946
----
959947
--
960948
====
@@ -987,14 +975,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=multi_arg_FieldSou
987975
Kotlin::
988976
+
989977
--
990-
[source,kotlin,indent=0]
991-
----
992-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=multi_arg_FieldSource_example]
978+
[source,kotlin]
993979
----
980+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=multi_arg_FieldSource_example,indent=0]
994981
995-
[source,kotlin,indent=0]
996-
----
997-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=stringIntAndListArguments]
982+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=stringIntAndListArguments,indent=0]
998983
----
999984
--
1000985
====
@@ -1407,19 +1392,13 @@ include::example$java/example/ParameterizedTestDemo.java[tags=repeatable_annotat
14071392
Kotlin::
14081393
+
14091394
--
1410-
[source,kotlin,indent=0]
1411-
----
1412-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=repeatable_annotations]
1395+
[source,kotlin]
14131396
----
1397+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=repeatable_annotations,indent=0]
14141398
1415-
[source,kotlin,indent=0]
1416-
----
1417-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=someProvider]
1418-
----
1399+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=someProvider,indent=0]
14191400
1420-
[source,kotlin,indent=0]
1421-
----
1422-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=otherProvider]
1401+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=otherProvider,indent=0]
14231402
----
14241403
--
14251404
====
@@ -1997,14 +1976,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=named_arguments]
19971976
Kotlin::
19981977
+
19991978
--
2000-
[source,kotlin,indent=0]
2001-
----
2002-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_arguments]
1979+
[source,kotlin]
20031980
----
1981+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_arguments,indent=0]
20041982
2005-
[source,kotlin,indent=0]
2006-
----
2007-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=namedArguments]
1983+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=namedArguments,indent=0]
20081984
----
20091985
--
20101986
====
@@ -2046,14 +2022,11 @@ include::example$java/example/ParameterizedTestDemo.java[tags=named_argument_set
20462022
Kotlin::
20472023
+
20482024
--
2049-
[source,kotlin,indent=0]
2050-
----
2051-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_argument_set]
2025+
[source,kotlin]
20522026
----
2027+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=named_argument_set,indent=0]
20532028
2054-
[source,kotlin,indent=0]
2055-
----
2056-
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=argumentSets]
2029+
include::example$kotlin/example/kotlin/ParameterizedTestDemo.kt[tag=argumentSets,indent=0]
20572030
----
20582031
--
20592032
====

documentation/src/test/kotlin/example/kotlin/ExternalFieldSourceDemo.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ import org.junit.jupiter.params.provider.FieldSource
1616
class ExternalFieldSourceDemo {
1717
// tag::external_field_FieldSource_example[]
1818
@ParameterizedTest
19-
@FieldSource("example.FruitUtils#tropicalFruits")
19+
@FieldSource("example.kotlin.FruitUtils#tropicalFruits")
2020
fun testWithExternalFieldSource(tropicalFruit: String) {
2121
// test with tropicalFruit
2222
}
2323
// end::external_field_FieldSource_example[]
2424
}
25+
26+
object FruitUtils {
27+
@JvmField
28+
val tropicalFruits: List<String> = listOf("pineapple", "kiwi")
29+
}

documentation/src/test/kotlin/example/kotlin/ExternalMethodSourceDemo.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11+
// tag::external_MethodSource_example[]
1112
package example.kotlin
1213

13-
// tag::external_MethodSource_example[]
1414
import org.junit.jupiter.params.ParameterizedTest
1515
import org.junit.jupiter.params.provider.MethodSource
16+
import java.util.stream.Stream
1617

1718
class ExternalMethodSourceDemo {
1819
@ParameterizedTest
19-
@MethodSource("example.StringsProviders#tinyStrings")
20+
@MethodSource("example.kotlin.StringsProviders#tinyStrings")
2021
fun testWithExternalMethodSource(tinyString: String) {
2122
// test with tiny string
2223
}
2324
}
25+
26+
object StringsProviders {
27+
@JvmStatic
28+
fun tinyStrings(): Stream<String> = Stream.of(".", "oo", "OOO")
29+
}
2430
// end::external_MethodSource_example[]

documentation/src/test/kotlin/example/kotlin/MethodSourceParameterResolutionDemo.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import java.util.stream.Stream
2323

2424
class MethodSourceParameterResolutionDemo {
2525
// tag::parameter_resolution_MethodSource_example[]
26+
@JvmField
27+
@RegisterExtension
28+
val integerResolver = IntegerResolver()
29+
2630
@ParameterizedTest
2731
@MethodSource("factoryMethodWithArguments")
2832
fun testWithFactoryMethodWithArguments(argument: String) {
@@ -41,17 +45,12 @@ class MethodSourceParameterResolutionDemo {
4145
): Any = 2
4246
}
4347
// end::parameter_resolution_MethodSource_example[]
44-
45-
companion object {
46-
@JvmField
47-
@RegisterExtension
48-
val integerResolver = IntegerResolver()
49-
50-
@JvmStatic
51-
fun factoryMethodWithArguments(quantity: Int): Stream<Arguments> =
52-
Stream.of(
53-
arguments("$quantity apples"),
54-
arguments("$quantity lemons")
55-
)
56-
}
5748
}
49+
50+
// tag::parameter_resolution_factory_MethodSource_example[]
51+
fun factoryMethodWithArguments(quantity: Int): Stream<Arguments> =
52+
Stream.of(
53+
arguments("$quantity apples"),
54+
arguments("$quantity lemons")
55+
)
56+
// end::parameter_resolution_factory_MethodSource_example[]

documentation/src/test/kotlin/example/kotlin/ParameterizedClassDemo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class ParameterizedClassDemo {
126126

127127
private fun assertFruit(fruit: String) {
128128
assertTrue(
129-
listOf("apple", "banana", "cherry", "dewberry").contains(fruit)
129+
fruit in listOf("apple", "banana", "cherry", "dewberry")
130130
) { "not a fruit: $fruit" }
131131
}
132132

0 commit comments

Comments
 (0)