【问题标题】:Eclipse not showing run as maven test when right click on maven project右键单击 Maven 项目时,Eclipse 未显示作为 Maven 测试运行
【发布时间】:2019-12-10 23:20:13
【问题描述】:

我已经通过 Eclipse 创建了一个 maven 项目,并将所有依赖项和插件添加到 pom.xml 文件中。现在,我在“src/test/java”文件夹下创建了一个包为“com.Qedge”,然后在 com.Qedge 包下创建了一个类,其中包含一段使用 JAVA 编写的代码。当我右键单击项目以作为“maven Test”运行时,Eclipse 没有在运行中显示该选项。当我右键单击项目的 pom.xml 文件时,我可以看到相同的选项。

我是 Maven 新手,我想知道这种行为有什么具体原因吗?我应该怎么做才能从项目文件夹中获得相同的选项(即右键单击项目 - 运行方式 - Maven 测试)。

请在下面找到我的 pom.xml 文件。

    <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.Qedge</groupId>
  <artifactId>MavenProjectDemo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>MavenProjectDemo</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
       <dependency>             
            <groupId>org.seleniumhq.selenium</groupId>                              
            <artifactId>selenium-java</artifactId>                              
            <version>2.53.1</version>                               
        </dependency>               
        <dependency>                
            <groupId>org.testng</groupId>                               
            <artifactId>testng</artifactId>                             
            <version>6.11</version>                             
            <scope>test</scope>                                     
       </dependency>
       <dependency>             
            <groupId>org.apache.poi</groupId>                               
            <artifactId>poi-ooxml</artifactId>                              
            <version>3.16</version>                             
            <scope>test</scope>                                     
       </dependency>
    </dependencies>

<build>  
    <pluginManagement> 
        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <inherited>true</inherited>
                <configuration>
                     <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                     </suiteXmlFiles>
                </configuration>
        </plugin>
        </plugins>
    </pluginManagement>
</build>
</project>

【问题讨论】:

    标签: java eclipse maven selenium-webdriver testng-eclipse


    【解决方案1】:

    右键单击您的项目Mark as Deployable。 以后就好了。

    【讨论】:

    • 当我右键单击项目时,没有这样的选项显示。
    【解决方案2】:

    右键项目,配置 -> 转换为 Maven 项目。

    【讨论】:

      猜你喜欢
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      • 2015-11-18
      • 1970-01-01
      • 1970-01-01
      • 2013-05-06
      • 2014-05-22
      • 1970-01-01
      相关资源
      最近更新 更多