Skip to content

Commit 7c52015

Browse files
committed
Extract Kotlin MyRandomParametersTest to separate file
Signed-off-by: Anton.Yalyshev <[email protected]>
1 parent 9e495dd commit 7c52015

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

documentation/modules/ROOT/pages/writing-tests/dependency-injection-for-constructors-and-methods.adoc

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Kotlin::
4141
--
4242
[source,kotlin,indent=0]
4343
----
44-
include::example$kotlin/example/KotlinTestInfoDemo.kt[tags=user_guide]
44+
include::example$kotlin/example/kotlin/TestInfoDemo.kt[tags=user_guide]
4545
----
4646
--
4747
====
@@ -81,7 +81,7 @@ Kotlin::
8181
--
8282
[source,kotlin,indent=0]
8383
----
84-
include::example$kotlin/example/KotlinTestReporterDemo.kt[tags=user_guide]
84+
include::example$kotlin/example/kotlin/TestReporterDemo.kt[tags=user_guide]
8585
----
8686
--
8787
====
@@ -124,19 +124,7 @@ Kotlin::
124124
--
125125
[source,kotlin,indent=0]
126126
----
127-
@ExtendWith(RandomParametersExtension::class)
128-
class KotlinMyRandomParametersTest {
129-
130-
@Test
131-
fun injectsInteger(@Random i: Int, @Random j: Int) {
132-
assertNotEquals(i, j)
133-
}
134-
135-
@Test
136-
fun injectsDouble(@Random d: Double) {
137-
assertEquals(0.0, d, 1.0)
138-
}
139-
}
127+
include::example$kotlin/example/kotlin/MyRandomParametersTest.kt[tags=user_guide]
140128
----
141129
--
142130
====
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2015-2026 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
package example.kotlin
12+
13+
// tag::user_guide[]
14+
import example.extensions.Random
15+
import org.junit.jupiter.api.Assertions.assertNotEquals
16+
import org.junit.jupiter.api.Test
17+
18+
class MyRandomParametersTest {
19+
@Test
20+
fun injectsInteger(
21+
@Random i: Int,
22+
@Random j: Int
23+
) {
24+
assertNotEquals(i, j)
25+
}
26+
}
27+
// end::user_guide[]

0 commit comments

Comments
 (0)