-
1. Re: How to define "contextRoot" in standalone Graphene tests
orbix42 Mar 18, 2015 1:03 PM (in response to christoffer)I'm just about to start implementing the same basic approach in my test suite, and I believe you should be able to define the base URL as a property within your arquillian.xml like this:
<arquillian>
<extension name="graphene">
<property name="url">http://localhost:8080/app/</property>
</extension>
</arquillian>
I found this info via the following Jira ticket: [ARQGRA-374] Allow to setup custom Location URL via arquillian.xml configuration with CustomizableURLResourceProvider - …
Like I said, I haven't had a chance to implement this yet, but hopefully my research will pay off for you!
-
2. Re: How to define "contextRoot" in standalone Graphene tests
christoffer Mar 18, 2015 6:00 PM (in response to orbix42)Hi David,
thanks for your input - I had found that possibility, but it did not change anything.
I finally found out why (and now it's working just fine) - in the GrapheneExtension class the following three lines stopped it from working for me:
if (SecurityActions.isClassPresent("org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider")) { builder.override(ResourceProvider.class, URLResourceProvider.class, CustomizableURLResourceProvider.class); }
Now, if you are following the approach here Functional Testing using Drone and Graphene · Arquillian Guides by just skipping the Arquillian (core) stuff from the earlier tutorials, you will end up with a pom.xml that does not import
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-impl-base</artifactId>
</dependency>which contains the URLResourceProvider class. So after I included that dependency, it worked like a charm.
Cheers, Chris
-
3. Re: How to define "contextRoot" in standalone Graphene tests
lfryc Mar 19, 2015 4:18 AM (in response to christoffer)Hey Christoffer,
nice catch,
I guess we should make the alternative approach and if URLResourceProvider is not found on classpath, we can safely register Graphene's own in an else branch, wdyt?
Would be great if you could create an issue and eventually send a PR. :-)
-
4. Re: How to define "contextRoot" in standalone Graphene tests
christoffer Mar 19, 2015 4:41 AM (in response to lfryc)Hi Lukas and David,
I filed a PR [ARQGRA-468] Cannot use relative @Location when using "standalone" JUnit integration - JBoss Issue Tracker
So my first described solution using the extra dependency is in fact no solution, because the extra dependency arquillian-container-test-impl-base brings too much stuff into the classpath that screws up JUnit.
So using
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-standalone</artifactId>
</dependency>together with
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-impl-base</artifactId>
</dependency>does NOT work, JUnit will try to execute the @Test method twice (I guess because of duplicate TestContextProvider or something like that).
What worked for me was to just use
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>lfryc The Graphene resource provider inherits from the URLResourceProvider :-(
-
5. Re: How to define "contextRoot" in standalone Graphene tests
lfryc Mar 19, 2015 5:47 AM (in response to christoffer)URLResourceProvider doesn't do anything special, it borrows just canProvide method that Graphene can reimplement itself.
So little bit of refactoring would be required inside CustomizableURLResourceProvider - use delegation pattern instead of inheritance: