gpt4 book ai didi

jboss-arquillian - 如何使用 ArquillianResource 注入(inject) URL?

转载 作者:行者123 更新时间:2023-12-04 07:27:36 26 4
gpt4 key购买 nike

我正在尝试使用 Arquillian Drone/Graphene 在一个简单的独立“hello world”测试中注入(inject) 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>

最佳答案

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

关于jboss-arquillian - 如何使用 ArquillianResource 注入(inject) URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16971414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com