2016-01-13 45 views
0

執行編輯:我已上載該項目的GitHub的人想看看https://github.com/hfunsh/test-automation.gitMaven構建成功,但沒有測試中硒

我寫的IntelliJ使用硒幾個測試,腳本誰在IDE中成功運行,但是當我嘗試從控制檯運行它們時,出現「BUILD SUCCESSFUL」消息,但沒有執行測試。

我可以從控制檯運行其他Maven Junit項目,所以我知道這很可能是我的pom文件的配置問題,但我無法弄清楚。

這裏是Java類名(包含單詞試驗)中的一個的示例

/用戶/ SER/IdeaProjects/SeleniunTrainingII/SRC /測試/ JAVA/COM /硒/測試/ junit的/測試/ TestLoginAmazon.java

第二編輯:我現在運行「MVN清潔驗證」的建議

INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Selenium tests project 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ selenium-app --- 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ selenium-app --- 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar (39 KB at 32.7 KB/sec) 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar (13 KB at 10.2 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar (48 KB at 40.5 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar (79 KB at 64.3 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar (153 KB at 123.5 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar (35 KB at 27.6 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar (66 KB at 52.7 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar (30 KB at 23.1 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-error-diagnostics/2.2.1/maven-error-diagnostics-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar (86 KB at 66.2 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar (26 KB at 19.3 KB/sec) 
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.jar 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar (22 KB at 16.6 KB/sec) 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-error-diagnostics/2.2.1/maven-error-diagnostics-2.2.1.jar (13 KB at 9.6 KB/sec) 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar (11 KB at 7.6 KB/sec) 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.jar (37 KB at 26.9 KB/sec) 
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar (174 KB at 126.2 KB/sec) 
[INFO] No tests to run. 
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}. 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ selenium-app --- 
[INFO] No tests to run. 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4.536 s 
[INFO] Finished at: 2016-01-14T10:10:47-05:00 
[INFO] Final Memory: 11M/108M 

編輯:現在我已經添加了兩個Maven的萬無一失和故障安全插件,以我的POM,它仍然ISN沒有工作。

這是我更新的文件是什麼樣子

<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.selenium.test</groupId> 
 
    <artifactId>selenium-app</artifactId> 
 
    <packaging>pom</packaging> 
 
    <version>1.0-SNAPSHOT</version> 
 
    <name>Selenium tests project</name> 
 
    <description>Web Autotests simple project.</description> 
 
    <url>http://maven.apache.org</url> 
 

 
    <properties> 
 
    <junit.version>4.11</junit.version> 
 
    <testng.version>6.8.17</testng.version> 
 
    <selenium.version>2.45.0</selenium.version> 
 
    <compiler.version>1.7</compiler.version> 
 
    </properties> 
 

 

 
    <build> 
 
    <plugins> 
 
     <plugin> 
 
     <groupId>org.apache.maven.plugins</groupId> 
 
     <artifactId>maven-compiler-plugin</artifactId> 
 
     <version>3.1</version> 
 
     <configuration> 
 
      <source>${compiler.version}</source> 
 
      <target>${compiler.version}</target> 
 
     </configuration> 
 
     </plugin> 
 
     <plugin> 
 
     <groupId>org.apache.maven.plugins</groupId> 
 
     <artifactId>maven-surefire-plugin</artifactId> 
 
     <version>2.19.1</version> 
 
     <configuration> 
 
      <systemPropertyVariables> 
 
      <propertyName>firefox</propertyName> 
 
      </systemPropertyVariables> 
 
     </configuration> 
 
     </plugin> 
 
     <plugin> 
 
     <groupId>org.apache.maven.plugins</groupId> 
 
     <artifactId>maven-failsafe-plugin</artifactId> 
 
     <version>2.18.1</version> 
 
     <executions> 
 
      <execution> 
 
      <configuration> 
 
       <forkCount>3</forkCount> 
 
       <reuseForks>true</reuseForks> 
 
       <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> 
 
       <testFailureIgnore>true</testFailureIgnore> 
 
       <includes> 
 
       <includesFile>**/*Test.java</includesFile> 
 
       </includes> 
 
      </configuration> 
 
      <goals> 
 
       <goal>integration-test</goal> 
 
       <goal>verify</goal> 
 
      </goals> 
 
      </execution> 
 
     </executions> 
 
     </plugin> 
 
    </plugins> 
 
    </build> 
 

 
    <dependencies> 
 
    <dependency> 
 
     <groupId>junit</groupId> 
 
     <artifactId>junit</artifactId> 
 
     <version>${junit.version}</version> 
 
    </dependency> 
 
    <dependency> 
 
     <groupId>org.testng</groupId> 
 
     <artifactId>testng</artifactId> 
 
     <version>${testng.version}</version> 
 
    </dependency> 
 
    <dependency> 
 
     <groupId>xml-apis</groupId> 
 
     <artifactId>xml-apis</artifactId> 
 
     <version>1.4.01</version> 
 
    </dependency> 
 
    <dependency> 
 
     <groupId>org.seleniumhq.selenium</groupId> 
 
     <artifactId>selenium-java</artifactId> 
 
     <version>${selenium.version}</version> 
 
    </dependency> 
 
    </dependencies> 
 
</project>

這裏是我的控制檯的輸出,以及從控制檯運行「MVN清潔試驗」後的POM文件。

[INFO] Scanning for projects... 
[INFO]                   
[INFO] -------------------------------------------------------------- 
[INFO] Building Selenium tests project 1.0-SNAPSHOT 
[INFO] -------------------------------------------------------------- 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ selenium-app 
[INFO] Deleting /Users/user/IdeaProjects/SeleniumTraining/target 
[INFO] BUILD SUCCESS 
[INFO] --------------------------------------------------------------  
[INFO] Total time: 0.350 s 
[INFO] Finished at: 2016-01-13T17:07:22-05:00 
[INFO] Final Memory: 6M/77M 
[INFO] ------------------------ 

我的POM:

<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.selenium.test</groupId> 
    <artifactId>selenium-app</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Selenium tests project</name> 
    <description>Web Autotests simple project.</description> 
    <url>http://maven.apache.org</url> 
    <properties> 
     <junit.version>4.12</junit.version> 
     <testng.version>6.8.17</testng.version> 
     <selenium.version>2.45.0</selenium.version> 
     <compiler.version>1.7</compiler.version> 
    </properties> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.12</version> 
     </dependency> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>${testng.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>xml-apis</groupId> 
      <artifactId>xml-apis</artifactId> 
      <version>1.4.01</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.48.0</version> 
     </dependency> 
    </dependencies> 
</project> 
+0

爲什麼Maven的命令你正在執行以獲得輸出嗎?你剛剛執行mvn clean嗎? –

+0

我跑了「mvn clean test」。 – HGF

+0

哪個文件夾包含您的硒測試? – eis

回答

1

樣品摘錄:

<plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.18.1</version> 
       <executions> 
        <execution> 
         <configuration> 
          <forkCount>3</forkCount> 
          <reuseForks>true</reuseForks> 
          <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> 
          <testFailureIgnore>true</testFailureIgnore> 
          <includes> 
           <includesFile>**/*Test.java</includesFile> 
          </includes> 
         </configuration> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

編輯:你的包名在TestLogin.java中是錯誤的。 編輯:另外你在pom.xml中的包裝設置爲pom..You需要將其設置爲罐子

+0

謝謝,我已經添加了兩個插件,都沒有工作。我已經發布了我的更新pom文件 – HGF

+0

原道歉..其實我的意思是你需要包括他們中的任何一個,似乎你沒有用相關的文件名替換包含標籤的測試..你還在運行什麼Maven目標? –

+0

我最初添加每個插件之前,決定在同一時間嘗試兩個。我還確保我的類文件名與包含標記中的模式匹配(即以Test.java結尾)。不幸的是我對maven的目標一無所知。 – HGF

0

添加Maven的萬無一失,插件,您的POM觸發TestNG的運行。您可以在documentation link中獲得有關maven surefire插件的更多信息。在POM

樣本插件條目:你需要或者maven-surefire-pluginmaven-failsafe-plugin添加到您的POM,然後運行mvn乾淨的測試命令和測試應該開始執行

<plugins> 
    [...] 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.19.1</version> 
     <configuration> 
      <systemPropertyVariables> 
      <propertyName>firefox</propertyName> 
      </systemPropertyVariables> 
     </configuration> 
     </plugin> 
    [...] 
</plugins> 
+0

謝謝,我試過這個,但它沒有奏效。我已經在原帖 – HGF

+0

上發佈了我的更新的pom文件,請嘗試'mvn -x'來找出調試信息運行序列中發生了什麼。 – parishodak

0

請確保您的測試目錄包含在pom.xml文件

<build> 
    <testSourceDirectory>your_test_source_directory</testSourceDirectory> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.19.1</version> 
     <configuration> 
      <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>      
      <suiteXmlFiles> 
       <suiteXmlFile>testng.xml</suiteXmlFile> 
      </suiteXmlFiles> 
      <includes> 
      <include>**.java</include> 
      </includes> 
     </configuration> 
    </plugin> 
</build> 
相關問題