当前位置: 首页 > 知识库问答 >
问题:

无法执行目标org.apache.maven.plugins: maven-sureFire插件: 2.10:测试没有执行测试

帅博远
2023-03-14

这是我添加的公共类NewEmptyJUnitTest的代码{

   @Test
  public void hello() {
    WebDriver driver  = new FirefoxDriver();
      driver.get("http://google.com");

    driver.quit();
  }
}

这是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>com.mycompany</groupId>
    <artifactId>SQEproject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>


    </properties>
    <dependencies>
        <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium</artifactId>
  <version>2.0b1</version>
  <exclusions>
    <exclusion>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
    </exclusion>
  </exclusions>
</dependency>
    <dependency>

       <groupId>io.ddavison</groupId>
       <artifactId>conductor</artifactId>
       <version>1.1</version>
   </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
            <version>2.44.0</version>
        </dependency>
        <dependency>
            <groupId>com.chrome</groupId>
            <artifactId>chromeriver</artifactId>
            <scope>test</scope>
            <version>1.5</version>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-remote-driver</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
            <version>4.11</version>
        </dependency>
    </dependencies>
</project>

我一直收到这个错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test

共有1个答案

蒯宏达
2023-03-14

SQEproject下没有JUnit的依赖关系。事实上,您已经添加了testng框架。因此,您需要添加Junit依赖项,正如您在下面添加的那样。

<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>SQEproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium</artifactId>
        <version>2.0b1</version>
        <exclusions>
        <exclusion>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
        <version>4.11</version>
   </dependency>
 类似资料: