The Arquillian Universe – Container Extensions – Arquillian Drone



The Arquillian Universe – Container Extensions – Arquillian Drone

0 0


JUDCON-India-2013


On Github VineetReynolds / JUDCON-India-2013

The Arquillian Universe

A tour around the astrophysics lab

JUDCON India 2013

Vineet Reynolds L. P.

Red Hat

Testing

too hard > too slow > no time > no fun

The purpose of automated testing is to enable change. Verifying correctness is just a nice side-effect. - Jeremy Norris

Core Principles

Tests should be portable to any supported container.
Tests should be executable from IDEs and build tools.
The platform should integrate existing test frameworks.

Arquillian Core

So you can rule your code, not the bugs!

Extensible

&

Flexible

Core extensions

You typically need these...

  • Container
  • Test

Test Extensions

Test as you usually do....

  • JUnit
  • TestNG

Or drive your development through stories/specifications...

  • Spock
  • JBehave*

Container Extensions

You want to run your tests like they're in production, right?

  • JBoss AS
  • GlassFish
  • Jetty
  • Tomcat
  • WebSphere
  • WebLogic
  • Spring, Weld
  • OpenShift
  • CloudBees
  • ...

Want more?

No problems!

You can implement your own.

Arquillian & the Testing pyramid

Arquillian Drone

Selenium/WebDriver for functional black box tests

Choice of browsers?

Target the ones your customers use.

What about HtmlUnit/PhantomJS?

Arquillian Warp

Don't let your black box tests fool you

This is cool. Where can I use it?

We're testing the UI and...

also performing state verification of 'testable' models or their substitutes.

Arquillian Persistence

So you don't fight your Data Access Layer

Rollback or Commit on every test?

Test your database engine thoroughly as early as you can.

  • In general,
  • Commit in component and integration tests.
  • Rollback in higher-level tests.
  • And cleanup correctly.

Transaction Isolation levels

@Test
@UsingDataSet("customer.xml")
@ShouldMatchDataSet("customer-with-account.xml")
public void testCreateAccountForCustomer() {
    // Setup. Query for a customer
    Customer customer = em.find(Customer.class, 1L);

    // Execute. Associate an account with the queried entity
    customerService.createAccount(customer);

    // Verify. Query for the updated customer
    // Avoid **this**, for REPEATABLE_READ/SERIALIZABLE
    em.flush();
    em.clear();
    Customer updatedCustomer = em.find(Customer.class, 1L);
    assertThat(updatedCustomer.getAccount(), equalTo(expectedAccount));
}
                            

Automate Dataset preparation

Dataset explosion?

  • Avoid large datasets (if you can).
  • Design and prepare datasets for reuse across tests.
  • It helps to store snapshots of entities across state transitions.

That's it?

Far from it!

  • Arquillian Graphene
  • Arquillian JRebel
  • Arquillian RushEye
  • Arquillian Performance
  • Arquillian Android

And...

  • Arquillian Byteman
  • Arquillian Seam2
  • Arquillian Portal
  • Arquillian Jacoco

And...

  • Arquillian Maven
  • Forge Plugin Arquillian