sure-fire插件在我的pom中有什么用

What is the use of sure-fire plugin in my pom

提问人:Ruchi 提问时间:2/2/2023 最后编辑:Ruchi 更新时间:2/2/2023 访问量:60

问:

在我的 pom.xml 中添加了两个 surefire 插件,我很困惑为什么要使用它们。

                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.0</version>
                        <configuration>
                            <!--<skipTests>false</skipTests>-->
                            <testFailureIgnore>true</testFailureIgnore>
                            <!--  <forkMode>once</forkMode> -->
                            <!-- Sets the VM argument line used when unit tests are run. -->
                            <argLine>${surefireArgLine}</argLine>
                            <includes>
                                <include>**/*TestApp.java</include>
                                <include>**/*Test.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                                    
                    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <!--    <skipTests>false</skipTests>-->
                    <testFailureIgnore>true</testFailureIgnore>
                    <!--  <forkMode>once</forkMode> -->

                    <includes>
                        <include>**/*TestApp.java</include>
                        <include>**/*Test.java</include>
                    </includes>
                    <argLine>-Xms128m</argLine>
                    <argLine>-Xmx512m</argLine>
                    <argLine>-XX:MaxPermSize=256m</argLine>
                </configuration>
            </plugin>

此外,如果我只是评论true,那么我的maven构建就会开始失败。有人可以解释一下吗,以及如何解决这个问题。 编辑 1 这是我运行 maven test 时的错误堆栈

**SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/eclipse-jee-2022-09-R-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime_3.8.601.20220820-1147/jars/maven-slf4j-provider-3.8.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/D:/eclipse-jee-2022-09-R-win32-x86_64/eclipse/configuration/org.eclipse.osgi/917/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.MavenSimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/eclipse-jee-2022-09-R-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime_3.8.601.20220820-1147/jars/maven-slf4j-provider-3.8.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/D:/eclipse-jee-2022-09-R-win32-x86_64/eclipse/configuration/org.eclipse.osgi/917/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.MavenSimpleLoggerFactory]
[[INFO[m] Scanning for projects...
[[mWARNING[m] 
[[mWARNING[m] Some problems were encountered while building the effective model for com.apc:designportal:war:22.1.2
[[mWARNING[m] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> duplicate declaration of version 4.12 @ line 430, column 15
[[mWARNING[m] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter. @ line 973, column 20
[[mWARNING[m] 
[[mWARNING[m] It is highly recommended to fix these problems because they threaten the stability of your build.
[[mWARNING[m] 
[[mWARNING[m] For this reason, future Maven versions might no longer support building such malformed projects.
[[mWARNING[m] 
[[INFO[m] 
[[INFO[m] [1m------------------------< [0;36mcom.apc:designportal[0;1m >------------------------[m
[[INFO[m] [1mBuilding SE Design Portal 22.1.2[m
[[INFO[m] [1m--------------------------------[ war ]---------------------------------[m
[[mWARNING[m] The POM for com.apc.designtools:dp-quotingsystem-integration:jar:0.4 is missing, no dependency information available
[[mWARNING[m] The artifact org.hibernate:hibernate-validator:jar:6.2.5.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.2.5.Final
[[mWARNING[m] The artifact javax.xml:jaxrpc:jar:1.1 has been relocated to javax.xml:jaxrpc-api:jar:1.1
[[INFO[m] 
[[INFO[m] [1m--- [0;32mmaven-resources-plugin:2.6:resources[m [1m(default-resources)[m @ [36mdesignportal[0;1m ---[m
[[mWARNING[m] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[[INFO[m] Copying 14 resources
[[INFO[m] Copying 83 resources
[[INFO[m] 
[[INFO[m] [1m--- [0;32mmaven-compiler-plugin:3.10.1:compile[m [1m(default-compile)[m @ [36mdesignportal[0;1m ---[m
[[INFO[m] Nothing to compile - all classes are up to date
[[INFO[m] 
[[INFO[m] [1m--- [0;32mmaven-resources-plugin:2.6:testResources[m [1m(default-testResources)[m @ [36mdesignportal[0;1m ---[m
[[mWARNING[m] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[[INFO[m] Copying 8 resources
[[INFO[m] 
[[INFO[m] [1m--- [0;32mmaven-compiler-plugin:3.10.1:testCompile[m [1m(default-testCompile)[m @ [36mdesignportal[0;1m ---[m
[[INFO[m] Nothing to compile - all classes are up to date
[[INFO[m] 
[[INFO[m] [1m--- [0;32mmaven-surefire-plugin:2.22.0:test[m [1m(default-test)[m @ [36mdesignportal[0;1m ---[m
[[INFO[m] 
[[INFO[m] -------------------------------------------------------
[[INFO[m]  T E S T S
[[INFO[m] -------------------------------------------------------
[[INFO[m] 
[[INFO[m] Results:
[[INFO[m] 
[[INFO[m] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[[INFO[m] 
[[INFO[m] [1m------------------------------------------------------------------------[m
[[INFO[m] [1;31mBUILD FAILURE[m
[[INFO[m] [1m------------------------------------------------------------------------[m
[[INFO[m] Total time:  3.939 s
[[INFO[m] Finished at: 2023-02-02T11:50:54+05:30
[[INFO[m] [1m------------------------------------------------------------------------[m
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-surefire-plugin:2.22.0:test[m [1m(default-test)[m on project [36mdesignportal[m: [1;31mThere are test failures.[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] [1;31mPlease refer to C:\Users\SESA701739\Downloads\Repository for openJDK17\designportal\target\surefire-reports for the individual test results.[m
[[1;31mERROR[m] [1;31mPlease refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.[m
[[1;31mERROR[m] [1;31mThe forked VM terminated without properly saying goodbye. VM crash or System.exit called?[m
[[1;31mERROR[m] [1;31mCommand was cmd.exe /X /C "D:\eclipse-jee-2022-09-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java -XX:MaxPermSize=256m -jar C:\Users\SESA70~1\AppData\Local\Temp\surefire14215564203121122107\surefirebooter2253485858284748685.jar C:\Users\SESA701739\AppData\Local\Temp\surefire14215564203121122107 2023-02-02T11-50-54_343-jvmRun1 surefire12140783555302454556tmp surefire_04303044982407970188tmp"[m
[[1;31mERROR[m] [1;31mError occurred in starting fork, check output in log[m
[[1;31mERROR[m] [1;31mProcess Exit Code: 1[m
[[1;31mERROR[m] [1;31morg.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?[m
[[1;31mERROR[m] [1;31mCommand was cmd.exe /X /C "D:\eclipse-jee-2022-09-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java -XX:MaxPermSize=256m -jar C:\Users\SESA70~1\AppData\Local\Temp\surefire14215564203121122107\surefirebooter2253485858284748685.jar C:\Users\SESA701739\AppData\Local\Temp\surefire14215564203121122107 2023-02-02T11-50-54_343-jvmRun1 surefire12140783555302454556tmp surefire_04303044982407970188tmp"[m
[[1;31mERROR[m] [1;31mError occurred in starting fork, check output in log[m
[[1;31mERROR[m] [1;31mProcess Exit Code: 1[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1194)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1022)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:868)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)[m
[[1;31mERROR[m] [1;31m  at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)[m
[[1;31mERROR[m] [1;31m  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[m
[[1;31mERROR[m] [1;31m  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)[m
[[1;31mERROR[m] [1;31m  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[m
[[1;31mERROR[m] [1;31m  at java.base/java.lang.reflect.Method.invoke(Method.java:568)[m
[[1;31mERROR[m] [1;31m  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)[m
[[1;31mERROR[m] [1;31m  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)[m
[[1;31mERROR[m] [1;31m  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)[m
[[1;31mERROR[m] [1;31m  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m] 
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m] 
[[1

> Blockquote

;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
[[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException**

And for this I'm unable to get the idea. If I just comment the testfailureIgnore true so that would not be a solution.

java maven pom.xml maven-plugin maven-surefire-plugin

评论

0赞 Mike 'Pomax' Kamermans 2/2/2023
Did you search the web first? Because it's part of standard Maven and has perfectly readable docs over on maven.apache.org/surefire/maven-surefire-plugin
0赞 khmarbaise 2/2/2023
The first thing you should learn is to follow conventions (over configuration) which means naming the unit tests like (details: maven.apache.org/surefire/maven-surefire-plugin/…) also I would question why you need to setup such large memory configuration for unit tests... Furthermore I strongly recommend to use more recent versions of the plugins (general reference: maven.apache.org/plugins) also this duplication in your pom file should produce warnings during the build.*Test.java
0赞 khmarbaise 2/2/2023
If you have failures during your build it's really necessary to post those error outputs here because we have no magic glas bulb where we can see your logs...
0赞 Ruchi 2/2/2023
@khmarbaise Please see the edit. Also, should I just remove the memory Configuration? because this is a heavy project so not sure on this part.
0赞 khmarbaise 2/2/2023
Check the failing tests and also the control sequences (color etc. are not helpful)... furthermore you have a lot of WARNING about deps. etc. Can you post your fuill pom file.... is that an OSGi project ?

答: 暂无答案