簡體   English   中英

我的測試正在運行,然后我單擊“運行為--> Maven clean”,現在當我單擊“運行為--> Maven 測試”時,它不再起作用

[英]My tests were running and then I clicked “Run as --> Maven clean” and now when I click “Run as --> Maven test” it doesn't work anymore

My project worked after right-clicking on the pom.xml file in Eclipse and selecting: "Run as --> Maven install" and then "Run as --> Maven test".

我開始嘗試並選擇:“運行方式--> Maven clean”,然后選擇“運行方式--> Maven 安裝”。 這次我遇到了構建錯誤,無法運行“運行為 --> Maven 測試”。 發生了什么? 為什么會出現構建錯誤?

如果我退出 Eclipse,刪除 .m2 文件夾中的所有內容,重新啟動 Eclipse,然后單擊“運行方式--> Z9115C10980645C41313F244AC1”,我可以讓測試再次運行訣竅)。 我不知道為什么會這樣。 我對“Maven clean”、“Maven install”和“Maven test”的作用感到困惑。 是的,我已經閱讀了maven.apache.org 上的文檔,但我仍然感到困惑。

這是我的 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.ah</groupId>
  <artifactId>goToLinks</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>GoToLinks</name>

    <dependencies>
        <!-- selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- cucumber-java -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>5.7.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>5.7.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <parallel>methods</parallel>
                    <useUnlimitedThreads>true</useUnlimitedThreads>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

這是我得到的錯誤:

 [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR: [INFO] ------------------------------------------------------------- [ERROR] Source option 5 is no longer supported. Use 7 or later. [ERROR] Target option 5 is no longer supported. Use 7 or later. [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.540 s [INFO] Finished at: 2020-06-01T19:47:03-04:00 [INFO] ------------------------------------------------------------------------

maven 編譯器插件默認為 Java 1.5,但您使用的 JDK 版本不再支持。 您可以通過將編譯器插件配置為使用不同版本的 java 來解決此問題。

https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.htmlZ

    <project>
      [...]
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
      [...]
    </project>

或者直接配置插件:

    <project>
      [...]
      <build>
        [...]
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
        </plugins>
        [...]
      </build>
      [...]
    </project>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM