File tree Expand file tree Collapse file tree 3 files changed +65
-27
lines changed
modules/ROOT/pages/writing-tests Expand file tree Collapse file tree 3 files changed +65
-27
lines changed Original file line number Diff line number Diff line change @@ -102,20 +102,7 @@ Java::
102102--
103103[source,java,indent=0]
104104----
105- @ExtendWith(RandomParametersExtension.class)
106- class MyRandomParametersTest {
107-
108- @Test
109- void injectsInteger(@Random int i, @Random int j) {
110- assertNotEquals(i, j);
111- }
112-
113- @Test
114- void injectsDouble(@Random double d) {
115- assertEquals(0.0, d, 1.0);
116- }
117-
118- }
105+ include::example$java/example/MyRandomParametersTest.java[tags=user_guide]
119106----
120107--
121108
@@ -124,19 +111,7 @@ Kotlin::
124111--
125112[source,kotlin,indent=0]
126113----
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- }
114+ include::example$kotlin/example/kotlin/MyRandomParametersTest.kt[tags=user_guide]
140115----
141116--
142117====
Original file line number Diff line number Diff line change 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 ;
12+
13+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
14+
15+ import example .extensions .Random ;
16+
17+ import org .junit .jupiter .api .Test ;
18+
19+ // tag::user_guide[]
20+ class MyRandomParametersTest {
21+
22+ private final int randomNumber ;
23+
24+ MyRandomParametersTest (@ Random int randomNumber ) {
25+ this .randomNumber = randomNumber ;
26+ }
27+
28+ @ Test
29+ void injectsInteger (@ Random int i , @ Random int j ) {
30+ assertNotEquals (i , j );
31+ }
32+
33+ }
34+ // end::user_guide[]
Original file line number Diff line number Diff line change 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+ @Random private val randomNumber : Int
20+ ) {
21+ @Test
22+ fun injectsInteger (
23+ @Random i : Int ,
24+ @Random j : Int
25+ ) {
26+ assertNotEquals(i, j)
27+ }
28+ }
29+ // end::user_guide[]
You can’t perform that action at this time.
0 commit comments