2012-07-03 4 views
0

셀렌 테스트를 실행하는 데 maven을 사용하고 있지만이 테스트를 찾지 못한 경우 src/test/java 아래에 넣습니다. 실행 한 후 여기 Maven에서 테스트를 볼 수 없습니다.

package functional; 
import com.thoughtworks.selenium.SeleneseTestCase; 
public class SeleniumTest extends SeleneseTestCase { 

    @Override 
    public void setUp() throws Exception { 
     setUp("http://www.netapsys.fr"); // délégation de la configuration à la classe parente 
    } 
    public void test() { 
     selenium.open("/"); // ouverture de la page 
     selenium.waitForPageToLoad("5000"); 
     assertTrue(selenium.isTextPresent("Netapsys")); 
    } 
} 

콘솔 결과입니다 :

<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.tests.functional.selenium</groupId> 
    <artifactId>functionalTestsSelenium</artifactId> 
    <packaging>war</packaging> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>functionalTestsSelenium Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.seleniumhq.selenium.client-drivers</groupId> 
      <artifactId>selenium-java-client-driver</artifactId> 
      <version>1.0.2</version> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 
    <build> 
     <finalName>functionalTestsSelenium</finalName> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.0.2</version> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat-maven-plugin</artifactId> 
       <version>1.0-beta-1</version> 
      </plugin> 


      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>selenium-maven-plugin</artifactId> 
      </plugin> 


      <!-- Start the tomcat server and Deploy the war --> 
      <plugin> 
       <groupId>org.codehaus.cargo</groupId> 
       <artifactId>cargo-maven2-plugin</artifactId> 
       <configuration> 
        <wait>false</wait> 
        <container> 
         <containerId>tomcat6x</containerId> 
         <type>installed</type> 
         <home>${env.CATALINA_HOME}</home> 
        </container> 
       </configuration> 
       <executions> 
        <execution> 
         <id>start-container</id> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>start</goal> 
          <goal>deploy</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>stop-container</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>stop</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 


      <!-- Start the selenium server --> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>selenium-maven-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>start</id> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>start-server</goal> 
         </goals> 
         <configuration> 
          <background>true</background> 
          <logOutput>true</logOutput> 
         </configuration> 
        </execution> 
        <execution> 
         <id>stop</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>stop-server</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

      <!-- Fire the function tests --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.4.3</version> 
       <configuration> 
        <junitArtifactname> 
         org.junit:com.springsource.org.junit 
        </junitArtifactname> 
        <excludes> 
         excluding the test class in the functional tests package 
         during the test phase 
         <exclude>**/functional/*Test.java</exclude> 
        </excludes> 
       </configuration> 
       <executions> 
        <execution> 
         <!-- Running the tests in the functional tests package during the integration tests phase. --> 
         <id>integration-tests</id> 
         <phase>integration-test</phase> 
         <goals> 
          <goal>test</goal> 
         </goals> 
         <configuration> 
          <skip>false</skip> 
          <excludes> 
           <exclude>none</exclude> 
          </excludes> 
          <includes> 
           <include>**/functional/*Test.java</include> 
          </includes> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

여기 내 테스트 클래스의 : 내 테스트 클래스는 여기에 코드입니다 SeleniumTest.java 이름이 그래서 규칙 (*Test.java를) 다음있다

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building seleniumproject Maven Webapp 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ seleniumproject --- 
[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] Copying 0 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ seleniumproject --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ seleniumproject --- 
[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] skip non existing resourceDirectory C:\Users\neila\workspace\seleniumproject\src\test\resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ seleniumproject --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ seleniumproject --- 
[INFO] No tests to run. 
[INFO] Surefire report directory: C:\Users\neila\workspace\seleniumproject\target\surefire-reports 
------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

[INFO] 
[INFO] --- maven-war-plugin:2.0.2:war (default-war) @ seleniumproject --- 
[INFO] Exploding webapp... 
[INFO] Assembling webapp seleniumproject in C:\Users\neila\workspace\seleniumproject\target\seleniumproject 
[INFO] Copy webapp webResources to C:\Users\neila\workspace\seleniumproject\target\seleniumproject 
[INFO] Generating war C:\Users\neila\workspace\seleniumproject\target\seleniumproject.war 
[INFO] Building war: C:\Users\neila\workspace\seleniumproject\target\seleniumproject.war 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.922s 
[INFO] Finished at: Wed Jul 04 08:18:56 GMT+01:00 2012 
[INFO] Final Memory: 5M/15M 
[INFO] ------------------------------------------------------------------------ 
+0

JUnit 4.x 버전을 사용해 보셨습니까? – romaintaz

+0

아니요,하지만 지금은 –

+0

어떻게 실행 하시겠습니까? 'mvn integration-test' (또는 그와 같은 것, 잊어 버렸습니다) 또는'mvn test' 만 실행하고 있습니까? –

답변

5

귀하의 테스트는 functional 패키지에 속합니다. pre-integration-testpost-integration-test 단계 동안 셀레늄 서버를

  <configuration> 
       <junitArtifactname> 
        org.junit:com.springsource.org.junit 
       </junitArtifactname> 
       <excludes> 
        excluding the test class in the functional tests package 
        during the test phase 
        <exclude>**/functional/*Test.java</exclude> 
       </excludes> 
      </configuration> 

귀하의 치어를 시작하도록 구성되어 있습니다 (정지) : 따라서, 귀하의 치어가 어떤 *functional* 패키지가 제외되도록 지정으로, 테스트 단계에서 실행되지 않습니다. 그러나이 단계에서는 테스트를 실행하지 않아도됩니다. integration-test 단계에서 셀렌 테스트를 실행하려면 failsafe Maven plugin을 살펴 보는 것이 좋습니다.

+1

나는 romaintaz에 동의하지만, 나는 또한 'maven에 대한 두 번째 실행을 정의 할 수 있어야한다고 생각한다. -surefire-plugin'을 사용하여 각 단계에서 * functional * 테스트를 수행 할 수 있습니다. – carlspring

+0

@carlspring 확실한 플러그인을 '통합 단계'에 바인딩하여 원하는대로 수행 할 수 있습니다. Maven 규칙을 따르는 통합 테스트를위한 failsafe 플러그인을 사용하는 것이 더 좋습니다 ... – romaintaz

관련 문제