Arquillian Graphene 2.0 - Functional Testing with Elegance

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 2.0.0.Final release of the Graphene component!

It’s already been a year since we announced the first alpha release of Graphene 2. Back then the Selenium project had undergone huge changes adopting the WebDriver API. We were excited to explore the new waters to make sure web applications are as easy to test as writing simple unit tests.

We quickly established some objectives for the project which evolved to what we can call Graphene 2.0 today:

  • built on top of WebDriver,
  • encourage to use/create reusable test abstractions,
  • simplify testing of AJAX pages.
  • fast development turnaround,

and last but not least, we wanted to make sure people could use the same features that were part of Graphene 1. Now, one and half year after the Graphene 1.0.0.Final release, we can finally report that we were able to rope in all of the concepts anticipated back then. During this journey we’ve basically touched all APIs and adopted all of the features while leveraging the modern WebDriver API for browser automation.

Graphene now consists of more than 700 commits from 11 code contributors – and that fact leads me to another aspect:

We would like to thank everyone who have been involved with the project so far; early adopters, issue reporters, people who improved documentation and of course people who picked up a ball and contributed to the code. You all hardened the project to the shape it is now.

Thank you, you guys rock!

How Graphene compares to WebDriver?

It’s important to say that Graphene is not just another dialect for WebDriver as we fully support the original WebDriver Java API. Instead, we add sensitive API extensions which we do believe altogether improves the experience and emphasizes ease of use – the common requirement for mass adoption.

We take the best of WebDriver such as

  • wide browser support,
  • object-oriented API,
  • testing design patterns such as Page Objects,

and we push them to the next level.

Graphene, together with its buddy Drone, are truly helpful for developers to lower the effort needed to build a reliable, robust and maintainable functional test suite. And we of course integrates seamlessly into the whole Arquillian test platform.

If you were to ask me; “whether you should just use the plain WebDriver API, or leverage Graphene?” the answer would be: you can continue using just WebDriver as you do today, and use as much or as little of Graphene as you see fit. Graphene just makes a few things a lot easier for you. The decision of which API to use can be compared to the decision you make when buying a new car – Should you buy a car with air-condition? Well, it certainly makes the ride a lot more pleasurable.

So, what’s so cool about Graphene?

Let’s go through some of the most prominent features:

Best Practices: Page Abstractions

As with WebDriver you can use Page Abstractions in the form of Page Objects. In Graphene we’ve made Page Abstractions a first class citizen, combined with dependency injection into the Arquillian test cases.

Graphene adds to this the concept of Page Fragments, which allows you to make even better abstractions. Page Fragments are so brilliant that e.g. the RichFaces project plan to offer fragments for testing their own widgets, in order to make your life super-easy.

public class UserDetailsPage {

    @FindBy(css = “.ui-timepicker”)
    private TimePicker birthday;

    public void setBirthDay(DateTime date) {
        birthday.setDate(date);
    }
}

public void TestCase {

    @Page
    private UserDetailsPage userDetails;

    @Test
    public void when_user_changes_birthday_then_admin_will_be_notified() {
        ...
        DateTime birthday = new Birthday(2012, 05, 04);
        userDetails.setBirthDay(birthday);
        ...
    }
}

Testing AJAX

Another area where Graphene excels is testing AJAX applications. In fact, Graphene doesn’t consider the WebElement as a concrete element on the target page, but rather as a proxy (or promise) for the real element that might be.

You no longer need to make sure the element you point to is not stale, since the proxy will make sure to bind to the most recent element for the given locator. This allows us to inject all Page Objects and their members using dependency injection during the start phase of the test. Members are then dereferenced as they are used.

Another useful feature is the Fluent Waiting API, which aims to better the readability of the test code.

Even more interesting is the use of Request Guards, which allow you to add synchronization points in your test logic when dealing with AJAX communication.

@FindByJQuery(“input:submit”)
private WebElement confirmButton;

@FindByJQuery(“body div.modal”)
private ModalPanel modalPanel;

// waits until a popup is opened
waitGui.until().element(popupPanel).is().visible();

// blocks until AJAX (XMLHttpRequest) communication is done
guardAjax(confirmButton).click();

Dependency Injection

Graphene is capable of providing injection of objects such as:

  • WebDriver context
  • interesting objects from WebDriver API e.g. JavascriptExecutor
  • elements using FindBy

into test objects such as:

  • Arquillian test case (class)
  • Page Objects
  • Page Fragments
  • WebElement wrappers, for example Select
@ArquillianResource
private WebDriver driver;

@ArquillianResource
private TakesScreenshot screenshotter;

You can find a complete list of resources available for injection in the Reference Documentation.

You can find a complete list of features in the Reference Documentation.

Learning Graphene

If you’re new to functional testing, I recommend you start by reading Functional Testing using Drone and Graphene which will guide you from the first build setup; through packaging parts of your application as a testable deployment and how to write your first test using Arquillian Graphene. It will give you an idea of how to structure the tests and give a few tips on how to write tests in a robust way.

Then you should focus on learning the WebDriver API.

If you already know the WebDriver API, I recommend you reading through the Reference Documentation which contain descriptions of all the Graphene features/goodies. Plus a few tips and tricks.

And finally, you can also read up on the JavaDoc.

Support and Compatibility Notes

We proactively test Graphene on Chrome, Firefox, Internet Explorer and PhantomJS, where we run our extensive test suite as part of the automated build. But generally speaking we support anything that Drone supports! We know for instance that Graphene also works on mobile devices such as Android.

From our experience, we also know that Graphene works great for testing web frameworks like JSF, GWT, AngularJS and generally it should work with any other web framework.

We hope that you’ll enjoy this new release and we look forward to your feedback on the community forum.
If you find any problems, have a new feature request, want some help spreading the word or want to show us a success story blog post, please don’t hesitate to contact us on the forum. All requests are welcome!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Graphene
Version 2.0.0.Final view tag
Release date 2013-10-11
Released by Lukas Fryc
Compiled against

Published artifacts org.jboss.arquillian.graphene

  • org.jboss.arquillian.graphene » graphene-parent pom
  • org.jboss.arquillian.graphene » graphene-webdriver pom
  • org.jboss.arquillian.graphene » arquillian-graphene pom
  • org.jboss.arquillian.graphene » graphene-webdriver-spi jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-webdriver-api jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-webdriver-impl jar javadoc pom

Release notes and resolved issues 10

Final release

Enhancement
Task
Sub-task

Thanks to the following list of contributors: Lukas Fryc

Arquillian OSGi 2.1.0.CR1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 2.1.0.CR1 release of the Arquillian OSGi component!

What is Arquillian OSGi?

ShrinkWrap is the simplest way to create archives in Java. Using the fluent and intuitive ShrinkWrap API, developers may assemble JARs, WARs, and EARs to be deployed directly by Arquillian during testing.

Release details

Component Arquillian OSGi
Modules
Version 2.1.0.CR1 view tag
Release date 2013-10-17
Released by Thomas Diesler
Compiled against

Published artifacts org.jboss.arquillian.osgi

  • org.jboss.arquillian.osgi » arquillian-osgi-protocol jar javadoc pom
  • org.jboss.arquillian.osgi » arquillian-osgi-testenricher jar javadoc pom
  • org.jboss.arquillian.osgi » arquillian-osgi-common jar javadoc pom
  • org.jboss.arquillian.osgi » arquillian-osgi-jbosgi-embedded jar javadoc pom
  • org.jboss.arquillian.osgi » arquillian-osgi-felix-embedded jar javadoc pom
  • org.jboss.arquillian.osgi » arquillian-osgi-karaf-embedded jar javadoc pom

Thanks to the following list of contributors: Thomas Diesler

Arquillian Droidium 1.0.0.Alpha2 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha2 release of the Arquillian Droidium component!

There are several important fixes in this release for those testing Android native and web applications in connection with Arquillian Drone and Graphene.

This release is packed with bugfixes and features which make the testing experience much smoother. The Arquillian Droidium container can from now on be used as a standalone container which does not depend on any plugin, native nor web. Even with no plugins on class path, you can still deploy APKs to Android device and you can fully interact with your device and automate it as you wish. Skys the limit…

Arquillian Droidium uses the Arquillian Drone and Graphene extensions heavily. Did you known that you can use Page fragments from Graphene on your native Android activities? That’s right, there is almost no difference between functional web and Android native application testing.

@RunWith(Arquillian.class)
@RunAsClient
public class AeroGearTestCase {

    @Drone
    @Browser
    WebDriver browser;

    @Drone
    @Mobile
    WebDriver mobile;

    ...

    @Browser
    @FindBy(id = "task-container")
    private TaskWebFragment taskFragment;

    @Mobile
    @FindBy(id = "todo")
    private TaskMobileFragment taskMobileFragment;

    ...

    @Test
    @InSequence(3)
    @OperateOnDeployment("todo-ear-app")
    public void addTask() {

        taskFragment.addTask("groceries", "buy some milk", "2020", "10", "20", "buy some fresh milk around the corner");

        Assert.assertEquals(taskFragment.getAddedTask().getTitle(), "buy some milk");
        Assert.assertEquals(taskFragment.getAddedTask().getDescription(), "buy some fresh milk around the corner");
    }

    @Test
    @InSequence(5)
    @OperateOnDeployment("todo-mobile-app")
    public void addMobileTask() {
        taskMobileFragment.addTask("mobile task", "2014-10-20", "task from mobile phone!");
    }

}

To see a full example of the Aerogear TODO demo app tested using Arquillian Droidium check out this repository.

Don’t know what Page Fragments are? You might want to read this blog post: Introducing Arquillian Graphene Page Fragments

Since you use can use the ordinary application container and Droidium container together in one test run, you can now test complex scenarios which require interaction between web application and Android application.

@Test
@InSequence(5)
@OperateOnDeployment("todo-mobile-app")
public void addMobileTask() {
    taskMobileFragment.addTask("mobile task", "2014-10-20", "task from mobile phone!");
}

@Test
@InSequence(6)
@OperateOnDeployment("todo-ear-app")
public void seeMobileTaskInWebClient() {
    browser.navigate().refresh();
}

We look forward to hearing your feedback about this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Droidium
Version 1.0.0.Alpha2 view tag
Release date 2013-10-09
Released by Karel Piwko
Compiled against

Published artifacts org.arquillian.container

  • org.arquillian.container » arquillian-droidium-container-api jar javadoc pom
  • org.arquillian.container » arquillian-droidium-container-spi jar javadoc pom
  • org.arquillian.container » arquillian-droidium-container jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-multiple-containers jar javadoc pom
  • org.arquillian.protocol » arquillian-protocol-android jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-native-api jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-native-spi jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-native-impl jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-native-depchain jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-web-spi jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-web-impl jar javadoc pom
  • org.arquillian.extension » arquillian-droidium-web-depchain jar javadoc pom
  • org.arquillian.droidium.archetype » arquillian-droidium-archetype-native-test jar javadoc pom
  • org.arquillian.droidium.archetype » arquillian-droidium-archetype-web-test jar javadoc pom

Release notes and resolved issues 14

Enhancement
  • ARQ-1506 - Rename Droidium Container artifactId
  • ARQ-1507 - Make usage of Arquillian Droidium stack easier
  • ARQ-1515 - Allow debugging mode for Selenium APK
  • ARQ-1524 - Implement deployment logic when native plugin is not on class path
  • ARQ-1526 - Provide screenshot api for Droidium container
Feature Request
  • ARQ-1495 - Support both serialId and avdName in arquillian.xml
  • ARQ-1521 - Implement default activity manager when native plugin is not on the class path
  • ARQ-1522 - Should be able to start activity without FQDN format
  • ARQ-1525 - Be able to deploy APKs when doing web testing with web plugin
Bug
  • ARQ-1505 - Wrong handling of Android Debug Bridge initialization
  • ARQ-1511 - Wrong Android container identification in logs
  • ARQ-1512 - Droidum does not handle disconnect of a physical device correctly
  • ARQ-1513 - Multicontainer extension should not log warnings about its property

Thanks to the following list of contributors: Stefan Miklosovic, Karel Piwko

Arquillian TestRunner Spock 1.0.0.Beta2 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Beta2 release of the Arquillian TestRunner Spock component!

“In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.”

Arquillian Spock Testrunner is back with the new version and bring important improvements in the area of specification execution. Yet again Karel Piwko evolves the Spock integration towards a Final release. He is the keeper of the state and you can rest assure he won’t let the two universes collide!

Important changes

Annotation driven activation is now obsolote
@ArquillianSpecification revealed itself to be more problematic than valuable (see JIRA issues below for details). Therefore we made a breaking change and got rid of it in favour for a custom test runner integrating both Spock and the Arquillian lifecycles. From now on you should simply decorate your specification with @RunWith(ArquillianSputnik).

Both Spock and Arquillian let you test your code with pleasure, so wait no more and give it a spin!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian TestRunner Spock
Version 1.0.0.Beta2 view tag
Release date 2013-10-08
Released by Karel Piwko
Compiled against

Published artifacts org.jboss.arquillian.spock

  • org.jboss.arquillian.spock » arquillian-spock-core jar javadoc pom
  • org.jboss.arquillian.spock » arquillian-spock-standalone jar javadoc pom
  • org.jboss.arquillian.spock » arquillian-spock-container jar javadoc pom

Release notes and resolved issues 5

Bug
  • ARQ-1427 - Arquillian Spock test fails with NPE when a subclass of spock.lang.Specification is used
  • ARQ-1429 - Spock Appender is missing org.objectweb.asm package
  • ARQ-1445 - Spock extension emits After/Before suite before/after each specification execution
  • ARQ-1480 - After/Before methods are always fired on both container/in client
  • ARQ-1481 - Remove redundancy of both ArquillianSputnik and ArquillianSpecification

Thanks to the following list of contributors: Karel Piwko, Aslak Knutsen, Bartosz Majsak

Arquillian Container WebSphere AS 1.0.0.Alpha2 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha2 release of the Arquillian Container WebSphere AS component!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Container WebSphere AS
Modules
Version 1.0.0.Alpha2 view tag
Release date 2013-10-02
Released by Aslak Knutsen
Compiled against

Published artifacts org.jboss.arquillian.container

  • org.jboss.arquillian.container » arquillian-was-remote-7 jar javadoc pom
  • org.jboss.arquillian.container » arquillian-was-embedded-8 jar javadoc pom
  • org.jboss.arquillian.container » arquillian-was-remote-8 jar javadoc pom
  • org.jboss.arquillian.container » arquillian-wlp-managed-8.5 jar javadoc pom

Release notes and resolved issues 9

Feature Request
  • ARQ-264 - Create a DeployableContainer integration for remote WAS V7.0
  • ARQ-423 - Create a DeployableContainer integration for remote WAS V8.0
  • ARQ-424 - Create a DeployableContainer integration for embeddable WAS V8.0
  • ARQ-1001 - Update WAS to Arquillian Core 1.0.0.Final
Bug
  • ARQ-625 - EnterpriseArchive deployment with EJB-JAR without descriptor will fail on WAS V8.0
  • ARQ-1434 - WAS should follow container artifact naming standard
  • ARQ-1463 - WebSphere Liberty Profile Container not working on Windows with IBM JVM
  • ARQ-1488 - CDI Injection not working in WebSphere Containers

Thanks to the following list of contributors: Gerhard Poul, Aslak Knutsen, Lebetz, Manuel Doninger