Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
org.apache.maven.LifecycleExecutionException:未能执行目标org.apache.maven.plugins:maven surefire plugin:2.12.4:测试_Maven_Selenium_Webdriver - Fatal编程技术网

org.apache.maven.LifecycleExecutionException:未能执行目标org.apache.maven.plugins:maven surefire plugin:2.12.4:测试

org.apache.maven.LifecycleExecutionException:未能执行目标org.apache.maven.plugins:maven surefire plugin:2.12.4:测试,maven,selenium,webdriver,Maven,Selenium,Webdriver,我是硒测试新手。当我试图构建我的项目时,我得到了以下错误。我曾多次尝试搜索堆栈溢出问题,但未能找到问题的实际解决方案 在下面共享my pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocatio

我是硒测试新手。当我试图构建我的项目时,我得到了以下错误。我曾多次尝试搜索堆栈溢出问题,但未能找到问题的实际解决方案

在下面共享my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>WebDriverTest</groupId>
    <artifactId>WebDriverTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-api</artifactId>
            <version>2.20</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
        </dependency>
    </dependencies>
    <!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugin</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> 
        </plugin> </plugins> </build> -->
</project>

我怀疑构建失败的另一个原因是我的一个jar被损坏。 对于org.testng.testng jar inside.m2文件夹,我得到了一个异常“无效LOC头(错误签名)”。 我删除了jar,并再次运行maven构建。该项目获得了成功

构建跟踪的一部分如下所示:

[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ WebDriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebDriverTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ WebDriverTest ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\celin\eclipse-workspace\WebDriverTest\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ WebDriverTest ---
[INFO] Surefire report directory: C:\Users\celin\eclipse-workspace\WebDriverTest\target\surefire-reports

从您的依赖项中删除所有maven surefire插件、surefire api、maven编译器插件-它们不属于那里!然后再试一次。谢谢。。它起作用了。。但我怀疑的问题是,我的testng jar已损坏。Maven使用校验和来验证jar。如果它是腐败的,Maven会在这件事上出错的。。当我删除这个罐子时,它起作用了。它对您的解决方案也很有效。
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ WebDriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebDriverTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ WebDriverTest ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\celin\eclipse-workspace\WebDriverTest\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ WebDriverTest ---
[INFO] Surefire report directory: C:\Users\celin\eclipse-workspace\WebDriverTest\target\surefire-reports