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