运行Maven时,无法在类路径和SurefireBooterForkException中找到类

时间:2018-07-06 11:46:33

标签: java eclipse maven selenium

使用maven和测试运行示例硒Java文件时遇到错误。

  1. 创建Maven项目
  2. 添加硒,测试依赖项和“确保射击”插件并在以下命令下运行。

    MVN全新安装  在此处输入代码     实际例外:     snarayana:com.ariba.selenium i339884 $ mvn干净测试     [INFO]正在扫描项目...     [信息]     [INFO] ----------------------------------------------- -------------------------     [INFO]建立com.ariba.selenium 1.0.0     [INFO] ----------------------------------------------- -------------------------     [信息]     [信息] --- maven-clean-plugin:2.5:clean(默认-clean)@ com.ariba.selenium ---     [INFO]删除/Users/i339884/Documents/maven/com.ariba.selenium/target     [信息]     [INFO] --- maven-resources-plugin:2.6:resources(default-resources)@ com.ariba.selenium ---     [警告]使用平台编码(实际上是UTF-8)来复制过滤的资源,即构建依赖于平台!     [INFO]跳过不存在的resourceDirectory /Users/i339884/Documents/maven/com.ariba.selenium/src/main/resources     [信息]     [INFO] --- maven-compiler-plugin:3.7.0:compile(default-compile)@ com.ariba.selenium ---     [INFO]没有资料可编译     [信息]     [INFO] --- maven-resources-plugin:2.6:testResources(default-testResources)@ com.ariba.selenium ---     [警告]使用平台编码(实际上是UTF-8)来复制过滤的资源,即构建依赖于平台!     [INFO]跳过不存在的resourceDirectory /Users/i339884/Documents/maven/com.ariba.selenium/src/test/resources     [信息]     [INFO] --- maven-compiler-plugin:3.7.0:testCompile(default-testCompile)@ com.ariba.selenium ---     [INFO]没有资料可编译     [信息]     [INFO] --- maven-surefire-plugin:2.21.0:test(默认测试)@ com.ariba.selenium ---     [INFO]没有要运行的测试。     [信息]     [INFO] ----------------------------------------------- --------     [信息] T E S T S     [INFO] ----------------------------------------------- --------     [INFO]运行TestSuite     [信息]     [INFO]结果:     [信息]     [INFO]测试运行:0,失败:0,错误:0,跳过:0     [信息]     [INFO] ----------------------------------------------- -------------------------     [INFO]建立失败     [INFO] ----------------------------------------------- -------------------------     [INFO]总时间:1.683 s     [INFO]完成于:2018-07-06T17:07:43 + 05:30     [INFO]最终内存:13M / 309M     [INFO] ----------------------------------------------- -------------------------     [错误]无法在项目com.ariba.selenium上执行目标org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test(默认测试):存在测试失败。     [错误]     [错误]有关各个测试结果,请参考/Users/i339884/Documents/maven/com.ariba.selenium/target/surefire-reports。     [错误]请参考转储文件(如果存在)[日期] -jvmRun [N] .dump,[日期] .dumpstream和[日期] -jvmRun [N] .dumpstream。     [ERROR]分叉的过程中出现错误     [错误]     [错误]在类路径中找不到类:com.test.selenium.TestHello     [错误] org.apache.maven.surefire.booter.SurefireBooterForkException:分叉过程中发生错误     [错误]     [错误]在类路径中找不到类:com.test.selenium.TestHello     org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:658)上的[错误]     org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)上的[错误]     org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)上的[错误]     org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)上的[错误]     org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider上的[错误](AbstractSurefireMojo.java:1149)     org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)上的[错误]     org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute([AbstractSurefireMojo.java:854)处的[错误]     org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)上的[错误]     org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)上的[错误]     org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)上的[错误]     org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)上的[错误]     org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)上的[错误]     org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)出现[错误]     org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)出现[错误]     org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)上的[错误]     org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)出现[错误]     org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)上的[错误]     org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)上的[错误]     org.apache.maven.cli.MavenCli.execute(MavenCli.java:955)出现[错误]     org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)的[错误]     org.apache.maven.cli.MavenCli.main(MavenCli.java:194)的[错误]     sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)处的[错误]     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)上的[错误]     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)上的[错误]     java.lang.reflect.Method.invoke上的[错误](Method.java:498)     org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)上的[错误]     org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)上的[错误]     org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)上的[错误]     org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)上的[错误]     [错误]     [错误]-> [帮助1]     [错误]     [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。     [错误]使用-X开关重新运行Maven以启用完整的调试日志记录。     [错误]     [ERROR]有关错误和可能的解决方案的详细信息,请阅读以下文章:     [错误] [帮助1]

http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ariba.selenium</groupId>
    <artifactId>com.ariba.selenium</artifactId>
    <!-- <packaging>jar</packaging> -->
    <version>1.0.0</version>

    <!-- <parent> <groupId>com.sap.ariba.swapnil</groupId> <artifactId>test_parent</artifactId> 
        <version>1.0.0-${MYBRANCH}</version> </parent> -->

    <dependencies>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <!-- Compiler plug-in -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <forkMode>never</forkMode>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <!-- Below plug-in is used to execute tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <inherited>true</inherited>
                <configuration>
                    <suiteXmlFiles>
                        <!-- TestNG suite XML files -->
                        <suiteXmlFile>/Users/i339884/Documents/maven/com.ariba.selenium/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

0 个答案:

没有答案