Reducing Java Enterprise Testing to Child’s Play

Testing...

Think again

You can’t fix what you can’t run

You can’t fix what you can’t debug

You can’t fix what you can’t test

You can’t develop if you can’t test

Testing is development

The purpose of automated testing is to enable change.

Verifying correctness is just a nice side-effect.


Jeremy Norris

Not testing is painful & time consuming

Testing eliminates this pain and sacrifice

Testing rulez!

Testing lens recap

Develop by testing

Don’t waste time being stuck

Our philosophy

1

Tests should be portable across compatible environments

2

Tests should be executable from the IDE and the build tool

3

The test platform should reuse existing frameworks and tools

testing-band-gap
invasion
Bring your tests to the runtime…
invasion
...so you rule your code, not the bugs!

arquillian - the enterprise test platform

⌖ arquillian.org

Designed for humans

IDE friendly ☺

Can be fully automated

Continuous integration, FTW! ∞

Provides a component model for testing

Dependency injection, yeah! ⤞

Isolates the code under test

Tame that classpath ⋔

test continuum

testing_continuum
Notes

this is the secret to making Java enterprise testing child’s play

Arquillian "Hello, World!" Test

@RunWith(Arquillian.class)
public class GreeterTest {

    @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class, "test.jar")
            .addClass(Greeter.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Inject
    Greeter greeter;

    @Test
    public void should_create_greeting() {
        Assert.assertEquals(
            "Hello, Earthling!", greeter.createGreeting("Earthling"));
    }
}

Run As... > JUnit Test

1-select-container
2-start-container
3-package-test-archive
4-run-test-in-container
5-collect-test-results
6-disconnect-container

arquillian - the extensible test platform

Notes
  • test runners
  • container adapters
  • test enrichers
  • integrations

Arquillian Persistence

incontainer_runmode

Arquillian Drone

client_runmode

Arquillian Warp

warp_runmode

Reject complex, jacked up test suites

Test continuum recap

You work in the IDE

CI servers work the build

Test to learn

Notes

Tests are the new "Hello, World!"

sci-4-3
Question everything

arquillian - a learning test platform

Write real tests

Real tests increase certainty

Real tests build confidence

Real tests increase robustness

Testing with mocks only proves you know how to write mocks

Learning recap

Use tests to learn

Keeps knowlege in the system

Final recap

Java enterprise testing + arquillian =
child’s play

Thanks!

Dan Allen