2016-12-22 9 views
0

테스트를 실행하기 전에 프로젝트 빌드를 실행할 때 chromedriver를 다운로드하여 압축을 풀어야합니다.maven 빌드에서 testng 테스트를 수행하기 전에 antrun 플러그인을 실행하십시오.

<dependencies> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-java</artifactId> 
     <version>3.0.1</version> 
    </dependency> 
    <dependency> 
     <groupId>org.testng</groupId> 
     <artifactId>testng</artifactId> 
     <version>6.8</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.relevantcodes</groupId> 
     <artifactId>extentreports</artifactId> 
     <version>2.41.2</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.8</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <configuration> 
         <target> 
          <get src="https://chromedriver.storage.googleapis.com/2.26/chromedriver_win32.zip" 
           dest="${project.basedir}" 
           verbose="false" 
           usetimestamp="true" /> 
          <unzip src="${project.basedir}/chromedriver_win32.zip" dest="${project.basedir}/drivers/" /> 
          <delete file="${project.basedir}/chromedriver_win32.zip" /> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.19.1</version> 
      <executions> 
       <execution> 
        <phase>test</phase> 
         <goals> 
          <goal>test</goal> 
         </goals> 
          <configuration> 
           <suiteXmlFiles> 
            <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
           </suiteXmlFiles> 
          </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

가 나중에 너무 테스트를 실행하기 위해, 내가 other questions에서 본으로도, 이후의 pom.xml에 확실한 플러그인을 선언는 antrun 플러그인을 사용하지만,있어 다운로드하려면 빌드는 드라이버를 다운로드하지 않았다 전에.

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building identificationkey 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ identificationkey --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory C:\Users\malibu\workspace\identificationkey\src\main\resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ identificationkey --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ identificationkey --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 2 resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ identificationkey --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ identificationkey --- 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running TestSuite 
Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 1.32 sec <<< FAILURE! - in TestSuite 
setUp(br.ufrn.imd.ihc.identificationkey.run.LoginTest) Time elapsed: 0.743 sec <<< FAILURE! 
java.lang.IllegalStateException: The driver executable does not exist: C:\Users\malibu\workspace\identificationkey\drivers\chromedriver.exe 
    at br.ufrn.imd.ihc.identificationkey.run.LoginTest.setUp(LoginTest.java:25) 


Results : 

Failed tests: 
    LoginTest.setUp:25 » IllegalState The driver executable does not exist: C:\Use... 

Tests run: 4, Failures: 1, Errors: 0, Skipped: 3 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 9.784 s 
[INFO] Finished at: 2016-12-22T17:52:02-03:00 
[INFO] Final Memory: 18M/244M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project identificationkey: There are test failures. 
[ERROR] 
[ERROR] Please refer to C:\Users\malibu\workspace\identificationkey\target\surefire-reports for the individual test results. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

내가 뭘 잘못하고 있니? 어떤 도움을 주시면 감사하겠습니다.

답변

0

빌드가 처리되는 순서를 나타내는 Maven 수명주기 (Introduction to the Build Lifecycle 참조)를 알아야합니다.

귀하의 경우, test 이후에 오는 귀하의 maven-antrun-plugin 실행에 대해 <phase>package</phase>을 지정하셨습니다.

사용 사례로는 <phase>process-test-resources</phase>과 같은 것을 사용합니다.