You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/docs/asciidoc/end-to-end-maven-guide.adoc
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,16 @@ This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment
232
232
233
233
Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website].
234
234
235
+
=== Build, but not execute native tests
236
+
237
+
During a transition phase, it is often useful to build tests but not execute them. This allows inspection of the generated test image without failing the build when the tests do not execute successfully.
238
+
239
+
If you wish to build, but not execute, the native tests, invoke Maven with the `-DskipTestExecution` switch or set the value in the plugin configuration.
240
+
241
+
=== Skip modules without native tests in multi-module builds
242
+
243
+
Multi-module projects where only some sub-modules contain native tests need to skip test execution for any module that do not contain native tests. Skip test execution for modules by setting the `<failNoTests>` configuration to `false` or providing `-DfailNoTests=false` on the command line.
244
+
235
245
[[gather-execution-profiles]]
236
246
=== Gather Execution Profiles and Build Optimized Images
Copy file name to clipboardExpand all lines: docs/src/docs/asciidoc/maven-plugin.adoc
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,18 @@ The following configuration options are available:
61
61
----
62
62
<skipNativeTests>true</skipNativeTests>
63
63
----
64
+
`<skipTestExecution>`::
65
+
Skips execution of native tests. If set to true, the plugin will create the native image for the tests but will not execute the tests. This allows the creation of the native image for testing even when tests don't fully execute or tests fail. Otherwise, the build stops at the first test failure. To skip only the execution of the native image compiled tests, add:
66
+
[source,xml, role="multi-language-sample"]
67
+
----
68
+
<skipNativeTests>true</skipNativeTests>
69
+
----
70
+
`<failNoTests>`::
71
+
Fails the build if no tests were found. In multi-module builds, there are often modules that have no tests (for example, a documentation module ) or where tests are enabled or disabled by profiles (such as slow tests, e2e tests, etc.). This switch allows for a global configuration of the native plugin and then allows you to skip any modules where no tests are present by changing this setting to false in the sub-module. This allows such multi-module projects to build successfully. To avoid failing the build in a module where no tests are present, add:
72
+
[source,xml, role="multi-language-sample"]
73
+
----
74
+
<failNoTests>false</failNoTests>
75
+
----
64
76
`<debug>`::
65
77
If you want to enable generation of debugging information, add:
66
78
[source,xml, role="multi-language-sample"]
@@ -686,6 +698,76 @@ For example, you might wish to disable only native testing support for use cases
686
698
- Your library or application uses a testing framework that is not supported on the JUnit Platform.
687
699
- You need to use the <<agent-support, agent>> when running tests on the JVM but do not wish to run those same tests as native code.
688
700
701
+
[[control-test-execution]]
702
+
=== Controlling test execution
703
+
704
+
==== Build, but not execute native tests
705
+
706
+
During a transition phase, it is often useful to build tests but not execute them. This allows inspection of the generated test image without failing the build when the tests do not execute successfully.
707
+
708
+
If you wish to build, but not execute, the native tests, invoke Maven with the `-DskipTestExecution` flag. This flag is specific to Native Build Tools.
709
+
710
+
[source,bash, role="multi-language-sample"]
711
+
----
712
+
./mvnw -Pnative -DskipTestExecution package
713
+
----
714
+
715
+
Alternatively, set `<skipTestExecution>` to `true` in the plugin configuration:
716
+
717
+
[source,xml, role="multi-language-sample"]
718
+
----
719
+
<configuration>
720
+
<skipTestExecution>true</skipTestExecution>
721
+
</configuration>
722
+
----
723
+
724
+
This will still build the native test image but skips execution of tests as native code.
725
+
726
+
==== Skip modules without native tests in multi-module builds
727
+
728
+
In multi-module projects where only some sub-modules contain native tests, you need to skip test execution for any module that does not contain native tests. Any module which should contain tests, but does not, should fail the build.
729
+
730
+
Skip test execution for modules by configuring the `<failNoTests>` configuration option for the full build and then overriding it in modules where the default behavior is not desired.
731
+
732
+
If the majority of the sub-modules should contain native tests, nothing needs to be configured globally since this is the default behavior for the native plugin.
733
+
734
+
For sub-modules that do not contain native tests but should not fail the build, add this to the module's _pom.xml_ in the module in the `<plugins>` section:
735
+
736
+
[source,xml, role="multi-language-sample"]
737
+
----
738
+
<plugin>
739
+
<groupId>org.graalvm.buildtools</groupId>
740
+
<artifactId>native-maven-plugin</artifactId>
741
+
<configuration>
742
+
<failNoTests>false</failNoTests>
743
+
</configuration>
744
+
</plugin>
745
+
----
746
+
747
+
If only a few sub-modules contain native tests, add this configuration setting to the main plugin configuration:
748
+
749
+
[source,xml, role="multi-language-sample"]
750
+
----
751
+
<configuration>
752
+
<failNoTests>false</failNoTests>
753
+
</configuration>
754
+
----
755
+
756
+
and then override this in any sub-module that should have native tests by adding this to the module in the `<plugins>` section:
757
+
758
+
[source,xml, role="multi-language-sample"]
759
+
----
760
+
<plugin>
761
+
<groupId>org.graalvm.buildtools</groupId>
762
+
<artifactId>native-maven-plugin</artifactId>
763
+
<configuration>
764
+
<failNoTests>true</failNoTests>
765
+
</configuration>
766
+
</plugin>
767
+
----
768
+
769
+
For testing from the command line, the `-DfailNoTests=false` flag is also supported directly:
0 commit comments