2

我正在尝试使用 Arquillian Drone/Graphene 在简单的独立“hello world”测试中注入 URL。也许我错过了一些明显的东西,但我找不到任何关于此的文档。

我在想可能有一些 system.properties(或 arquillian.xml)我可以这样设置:

<systemPropertyVariables>
    <arq.extension.graphene.xxx>http://www.google.com</arq.extension.graphene.xxx>
</systemPropertyVariables>

这是我的简单测试:

@RunWith(Arquillian.class)
public class DummyTest
{
    @Drone
    GrapheneSelenium browser;

    @ArquillianResource
    URL url;

//    URL url = URLUtils.buildUrl("http://www.google.com/");

   @Test
   public void openBrowser()
   {
      browser.open(url);
   }
}

这是pom:

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.arquillian.example</groupId>
    <artifactId>arquillian-tutorial</artifactId>
    <version>1.0.0-SNAPSHOT</version>   
    <properties>
        <version.junit>4.11</version.junit>
        <version.arquillian_core>1.0.4.Final</version.arquillian_core>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>${version.arquillian_core}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.graphene</groupId>
            <artifactId>arquillian-graphene</artifactId>
            <version>2.0.0.Alpha4</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>arquillian-tutorial</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14.1</version>
            </plugin>
        </plugins>
    </build>
</project>
4

1 回答 1

8

URL注入仅适用于客户端部署,因此您需要标记您的 test @RunAsClient。或者,它可以注入任何@Test标记@RunAsClient为测试参数的方法中。

于 2013-06-08T16:18:16.717 回答