The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen...
Transcript of The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen...
![Page 1: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/1.jpg)
The future of enterprise testingThe future of enterprise testing
Aslak KnutsenAslak KnutsenJBoss, by Red HatJBoss, by Red Hat aslakknutsenaslakknutsen
Dan AllenDan AllenJBoss, by Red HatJBoss, by Red Hat mojavelinuxmojavelinux
![Page 2: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/2.jpg)
2
Agenda
● Why Java EE is harder than it should be● How component models apply to testing● Tools that help you develop & test with confidence
● ShrinkWrap - Skip the build● Arquillian - Test in-container
● Demo, demo, demo● What's coming next, with demos
#arquillian
![Page 3: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/3.jpg)
3
No tests #fail
![Page 4: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/4.jpg)
4
Unit tests vs integration tests
Unit● Attributes
● Fine-grained● Simple● Single API call
● Perception● Fast, fast, fast● Easily run in an IDE
Integration● Attributes
● Coarse-grained● Complex● Component interactions
● Perception● Sloooooooow● Run in an IDE? How?
![Page 5: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/5.jpg)
5
The testing “bandgap”
Unit Tests Integration Tests System Tests
Functionality
Setup & configuration
Com
plex
ity (
Men
tal E
ffort)
![Page 6: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/6.jpg)
6
What if integration testing could be...?
● as easy as writing a unit test● run in the IDE (incremental builds, debugging, etc)● ramped up in phases● portable
![Page 7: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/7.jpg)
7
Component models make life easier
● Component● Follows standard programming model● Encapsulates business logic● Packaged in deployable archive
● Container● Host process for deployed applications● Provides services and a runtime for components● Gives you powerful mechanisms for free
![Page 8: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/8.jpg)
8
What's been from Java EE?missing
^
![Page 9: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/9.jpg)
9
A component model for your tests
![Page 10: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/10.jpg)
10
Reducing enterprise testing to child's play
Unit Tests Integration Tests System Tests
Functionality
Setup & configuration
Arquillian's test continuum
Com
plex
ity (
Men
tal E
ffort)
![Page 11: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/11.jpg)
11
How do we get there?
![Page 12: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/12.jpg)
12
Test in-container!Test in-container!Skip the build!
![Page 13: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/13.jpg)
13
n. a fluent API for creating archives such as JARs, WARs andEARs in Java
Project lead: Andrew Lee Rubinger
http://jboss.org/shrinkwrap
![Page 14: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/14.jpg)
14
Benefits of ShrinkWrap
● Incremental IDE compilation● Save and re-run● Skip the build!
● Simple, fluent API● Container deployment adapters● Micro deployments● Export and debugging
![Page 15: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/15.jpg)
15
Fluent archive creationJavaArchive archive = ShrinkWrap.create(JavaArchive.class, "slsb.jar") .addClasses(Greeter.class, GreeterBean.class);System.out.println(archive.toString(true));
slsb.jar:/com//com/acme//com/acme/app//com/acme/app/ejb3//com/acme/app/ejb3/Greeter.class/com/acme/app/ejb3/GreeterBean.class
Yields output:
![Page 16: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/16.jpg)
16
n. a container-oriented testing framework that enablesdevelopers to create portable integration tests for enterpriseapplications; manages the lifecycle of a container and enriches,deploys and runs tests in the container or as a client
Project lead: Aslak Knutsen
http://jboss.org/arquillian
![Page 17: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/17.jpg)
17
An in-container approach to integration testing
1. Start or connect to a container2. Package and deploy test case to container3. Run test in-container4. Capture and report results5. Undeploy test archive
Bring your test to the runtime...
...instead of managing the runtime from your test.
![Page 18: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/18.jpg)
18
Make integration testing a breeze!
Arquillian project mission
![Page 19: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/19.jpg)
19
Prove it.@RunWith(Arquillian.class)public class GreeterTestCase {
@Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClasses(Greeter.class, GreeterBean.class); } @EJB Greeter greeter; @Test public void shouldBeAbleToInvokeEJB() { Assert.assertEquals("Hello, Earthlings", greeter.greet("Earthlings")); }}
![Page 20: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/20.jpg)
20
What's on the way?What's on the way?
![Page 21: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/21.jpg)
21
● Full-on, container invasion● Multi-deployment, multi-container, multi-node per test● Sophisticated configuration
● ShrinkWrap descriptors● Fluent API for creating/modifying XML descriptors
● Container metadata● Configuration (e.g., ports, urls)● Deployment information (e.g., context path)
● Dependency management● Isolated container dependencies● Adding libraries to test archive
![Page 22: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/22.jpg)
22
Power tools: test framework integration
● Test frameworks are services too!● Extends test component model● Examples:
● JSFUnit*● Cobertura*● Spock*● Selenium*● HTTPUnit● DBUnit
* available
![Page 23: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/23.jpg)
23
![Page 24: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/24.jpg)
24
Benefits of Arquillian
● Write less (boilerplate) test code● As much or as little “integration” as you need● Looks like a unit test, but you're in a true environment!● Run same test in multiple containers● It's a learning environment
![Page 25: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/25.jpg)
25
Arquillian...
● is a container-oriented testing framework● provides a component model for tests● handles test infrastructure & plumbing● ships with a set of container implementations● saves your fail ;)
![Page 26: The future of enterprise testing - Jfokus€¦ · The future of enterprise testing Aslak Knutsen JBoss, by Red Hat aslakknutsen ... Reducing enterprise testing to child's play Unit](https://reader033.fdocuments.in/reader033/viewer/2022042322/5f0cf7347e708231d43802a1/html5/thumbnails/26.jpg)
26
Get involved!
● Download us!● ShrinkWrap - http://jboss.org/shrinkwap● Arquillian - http://jboss.org/arquillian
● Participate with us!● Community Space
● Fork us!● Meet us!
● #jbosstesting channel on irc.freenode.net● Write for us!
● Share your stories – Blog! Tweet! #arquillian● Document how it works