Skip to content

Commit d21fb36

Browse files
committed
Move JUnit tests to get started
1 parent 14c95f8 commit d21fb36

File tree

2 files changed

+82
-82
lines changed

2 files changed

+82
-82
lines changed

docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,38 @@ This command will compile your application and create a native executable in the
5555
./gradlew nativeRun
5656
----
5757

58-
Continue reading below to learn more about the plugin.
58+
Continue to advanced use cases to learn more about the plugin.
59+
60+
[[run-junit-tests]]
61+
=== Run Junit Tests
62+
63+
This plugin supports running tests on the JUnit Platform.
64+
The tests are compiled ahead of time and executed as native code.
65+
66+
- Add the JUnit 5 dependency to _build.gradle_ / _build.gradle.kts_ to include the testing framework:
67+
68+
[source,groovy,role="multi-language-sample"]
69+
----
70+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
71+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
72+
testImplementation 'junit:junit:4.13.2'
73+
----
74+
75+
[source,kotlin,role="multi-language-sample"]
76+
----
77+
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1')
78+
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.1')
79+
testImplementation('junit:junit:4.13.2')
80+
----
81+
82+
- Run the tests:
83+
84+
[source,bash,role="multi-language-sample"]
85+
----
86+
./gradlew nativeTest
87+
----
88+
89+
The tests are compiled ahead of time and executed as native code.
5990

6091
[[advanced-use-cases]]
6192
== Advanced Use Cases: How to
@@ -134,37 +165,6 @@ This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment
134165

135166
Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website].
136167

137-
[[run-junit-tests]]
138-
=== Run Junit Tests
139-
140-
This plugin supports running tests on the JUnit Platform.
141-
The tests are compiled ahead of time and executed as native code.
142-
143-
- Add the JUnit 5 dependency to _build.gradle_ / _build.gradle.kts_ to include the testing framework:
144-
145-
[source,groovy,role="multi-language-sample"]
146-
----
147-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
148-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
149-
testImplementation 'junit:junit:4.13.2'
150-
----
151-
152-
[source,kotlin,role="multi-language-sample"]
153-
----
154-
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1')
155-
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.1')
156-
testImplementation('junit:junit:4.13.2')
157-
----
158-
159-
- Run the tests:
160-
161-
[source,bash,role="multi-language-sample"]
162-
----
163-
./gradlew nativeTest
164-
----
165-
166-
The tests are compiled ahead of time and executed as native code.
167-
168168
[[gather-execution-profiles]]
169169
=== Gather Execution Profiles and Build Optimized Images
170170

@@ -444,4 +444,4 @@ All the monitoring and debugging tools https://www.graalvm.org/reference-manual/
444444

445445
=== Learn more
446446

447-
To continue learning, refer to the <<changelog.adoc#,extensive reference documentation for the GraalVM Native Image Gradle plugin>>.
447+
To continue learning, refer to the <<gradle-plugin.adoc#,Gradle plugin documentation>>.

docs/src/docs/asciidoc/end-to-end-maven-guide.adoc

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -103,54 +103,6 @@ This command will compile your application and create a native executable in the
103103
You can have multiple profiles, which is very convenient if you want to produce different versions of your native images for your application (optimized, static, and others).
104104
Continue to advanced use cases to learn more.
105105

106-
[[advanced-use-cases]]
107-
== Advanced Use Cases: How to
108-
109-
For advanced use cases, this guide provides instructions for configuring the build process, running tests on native code, gathering execution profiles, troubleshooting missing configuration, and enabling diagnostic tools to analyze native images.
110-
111-
[[configure-image-build]]
112-
=== Configure Native Image Build
113-
114-
The plugin supports passing options directly to Native Image inside the `<configuration>` block.
115-
Using `<buildArg>`, you can pass any Native Image build option listed on https://www.graalvm.org/reference-manual/native-image/overview/Options/[this page].
116-
117-
The plugin also provides special properties to configure the build:
118-
119-
- `<environment>` - Sets the environment options
120-
- `<imageName>` - Specifies of the name for the native executable file. If a custom name is not supplied, the artifact ID of the project will be used by default (defaults to the project name).
121-
- `<jvmArgs>` - Passes the given argument directly to the JVM running the `native-image` tool
122-
- `<quickBuild>` - Enables quick build mode
123-
- `<verbose>` - Enables the verbose output
124-
- and many more https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#configuration-options[listed here].
125-
126-
Here is an example of additional options usage:
127-
[source,xml, role="multi-language-sample"]
128-
----
129-
<configuration>
130-
<mainClass>org.example.Main</mainClass>
131-
<imageName>myApp</imageName>
132-
<verbose>true</verbose>
133-
<buildArgs>
134-
<buildArg>-O3</buildArg> <!-- enables additional compiler optimizations -->
135-
</buildArgs>
136-
<environment>
137-
<variable1>value1</variable1>
138-
<variable2>value2</variable2>
139-
</environment>
140-
<jvmArgs>
141-
<arg>your-argument</arg>
142-
</jvmArgs>
143-
</configuration>
144-
----
145-
146-
[TIP]
147-
====
148-
As an alternative, you can pass additional build options via the `NATIVE_IMAGE_OPTIONS` environment variable, on the command line.
149-
This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment variable is prefixed to the options supplied to `native-image`.
150-
====
151-
152-
Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website].
153-
154106
[[run-junit-tests]]
155107
=== Run Junit Tests
156108

@@ -232,6 +184,54 @@ Alternatively, set `<skipNativeTests>` to `true` in the plugin configuration:
232184

233185
This way you configure your Maven profile to skip generation and execution of tests as native code.
234186

187+
[[advanced-use-cases]]
188+
== Advanced Use Cases: How to
189+
190+
For advanced use cases, this guide provides instructions for configuring the build process, running tests on native code, gathering execution profiles, troubleshooting missing configuration, and enabling diagnostic tools to analyze native images.
191+
192+
[[configure-image-build]]
193+
=== Configure Native Image Build
194+
195+
The plugin supports passing options directly to Native Image inside the `<configuration>` block.
196+
Using `<buildArg>`, you can pass any Native Image build option listed on https://www.graalvm.org/reference-manual/native-image/overview/Options/[this page].
197+
198+
The plugin also provides special properties to configure the build:
199+
200+
- `<environment>` - Sets the environment options
201+
- `<imageName>` - Specifies of the name for the native executable file. If a custom name is not supplied, the artifact ID of the project will be used by default (defaults to the project name).
202+
- `<jvmArgs>` - Passes the given argument directly to the JVM running the `native-image` tool
203+
- `<quickBuild>` - Enables quick build mode
204+
- `<verbose>` - Enables the verbose output
205+
- and many more https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#configuration-options[listed here].
206+
207+
Here is an example of additional options usage:
208+
[source,xml, role="multi-language-sample"]
209+
----
210+
<configuration>
211+
<mainClass>org.example.Main</mainClass>
212+
<imageName>myApp</imageName>
213+
<verbose>true</verbose>
214+
<buildArgs>
215+
<buildArg>-O3</buildArg> <!-- enables additional compiler optimizations -->
216+
</buildArgs>
217+
<environment>
218+
<variable1>value1</variable1>
219+
<variable2>value2</variable2>
220+
</environment>
221+
<jvmArgs>
222+
<arg>your-argument</arg>
223+
</jvmArgs>
224+
</configuration>
225+
----
226+
227+
[TIP]
228+
====
229+
As an alternative, you can pass additional build options via the `NATIVE_IMAGE_OPTIONS` environment variable, on the command line.
230+
This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment variable is prefixed to the options supplied to `native-image`.
231+
====
232+
233+
Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website].
234+
235235
[[gather-execution-profiles]]
236236
=== Gather Execution Profiles and Build Optimized Images
237237

@@ -500,4 +500,4 @@ You will find the output of these tools among the generated artifacts after runn
500500

501501
=== Learn more
502502

503-
To continue learning, refer to the <<changelog.adoc#,extensive reference documentation for the GraalVM Native Image Maven plugin>>.
503+
To continue learning, refer to the <<maven-plugin.adoc#,Maven plugin documentation>>.

0 commit comments

Comments
 (0)