2013-03-06 78 views
1

我試圖用Arquillian Drone來驅動我的測試,但是,出於某種原因註釋@Before@After@BeforeClass@AfterClass被完全忽略後。的Arquillian無人機完全無視之前課餘BeforeClass註釋

我是新來的這個Java/jUnit/Arquillian環境(一直在使用Python),所以我可能會在這裏犯一些愚蠢的錯誤。

import org.jboss.arquillian.drone.api.annotation.Drone; 
import org.jboss.arquillian.junit.Arquillian; 

import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 


import com.eyereturn.warlock.client.pages.login.LoginPage; 

@RunWith(Arquillian.class) 
public class TestDroneLogin { 

    @Drone 
    private WebDriver driver; 

    @Before 
    public void setup(){ 
     driver.navigate().to("http://google.com"); 
    } 

    @Test 
    public void testInput(){ 
     driver.findElement(By.cssSelector("input#gbqfq")); 
    } 
} 

arquillian.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<arquillian xmlns="http://jboss.org/schema/arquillian" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://jboss.org/schema/arquillian 
     http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> 

    <extension qualifier="webdriver"> 
     <property name="browserCapabilities">chrome</property> 
    </extension> 

</arquillian> 

的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.myproj</groupId> 
    <artifactId>proj-integration-tests</artifactId> 
    <version>1.0.0-SNAPSHOT</version> 
    <name>Project Integration Tests</name> 

    <properties> 
     <maven.compiler.source>1.6</maven.compiler.source> 
     <maven.compiler.target>1.6</maven.compiler.target>  
    </properties> 

    <dependencies> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.1</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.31.0</version> 
     </dependency> 

     <!-- Arquillian Core dependencies --> 
     <dependency> 
      <groupId>org.jboss.arquillian</groupId> 
      <artifactId>arquillian-bom</artifactId> 
      <version>1.0.3.Final</version> 
      <scope>compile</scope> 
      <type>pom</type> 
     </dependency> 

     <!-- Arquillian Drone dependencies and Selenium dependencies --> 
     <dependency> 
      <groupId>org.jboss.arquillian.extension</groupId> 
      <artifactId>arquillian-drone-bom</artifactId> 
      <type>pom</type> 
      <version>1.1.1.Final</version> 
      <scope>compile</scope> 
     </dependency> 

     <!-- Arquillian Graphene Webdriver --> 
     <dependency> 
      <groupId>org.jboss.arquillian.graphene</groupId> 
      <artifactId>graphene-webdriver</artifactId> 
      <version>2.0.0.Alpha3</version> 
      <type>pom</type> 
      <scope>test</scope> 
     </dependency> 

     <!-- Arquillian JUnit Standalone --> 
     <dependency> 
      <groupId>org.jboss.arquillian.junit</groupId> 
      <artifactId>arquillian-junit-standalone</artifactId> 
      <version>1.0.3.Final</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 
</project> 

回答

5

看起來這是Arquillian Standalone版本一直存在的問題。

該錯誤是開放的here,但是自2012年8月14日以來沒有收到任何關注

的解決方法是在pom.xml使用「的Arquillian JUnit的容器」版本而不是 「的Arquillian JUnit的獨立」 的:

<!-- Arquillian JUnit Container --> 
    <dependency> 
     <groupId>org.jboss.arquillian.junit</groupId> 
     <artifactId>arquillian-junit-container</artifactId> 
     <version>1.0.3.Final</version> 
     <scope>test</scope> 
    </dependency> 

這似乎爲我工作。

注意:當使用@BeforeClassDrone看出來this bug