Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Greetings, 
Earthlings!
1 Tests should be 
portable to any supported container
2 Tests should be 
executable from both IDE and build tool
3 The platform should 
extend/integrate existing test 
frameworks
The basics
Arquillian Core 
so you can rule the code, not the bugs!
Testing 
platform 
Middleware for your tests
Modular, Extensible, Flexible
Test Extension 
SPI for test runners
Test Runners 
JUnit · TestNG · Spock · JBehave · Cucumber · Thucydides
Container 
Extension 
SPI for runtime providers
Container 
Adapters 
WildFly · JBoss EAP · GlassFish · TomEE · Jetty · Tomcat · 
WebSphere · WebLogic · Spring · Weld · OS...
Container Test 
Extension 
Binds the two ⇒ In container testing
The basic Test Class
public class MyTestClass { 
private MyBean bean = new MyBeanStub(); 
@Test 
public void shouldBeAbleTo() { 
Assert.assertN...
@RunWith(Arquillian.class) 
public class MyTestClass { 
@Deployment 
public static Archive<?> createDeployment() { 
return...
Demo
How does this all work?
Setup 
Maven, Gradle, Ant(+Ivy)
<dependencyManagement> 
<dependency> 
<groupId>org.jboss.arquillian</groupId> 
<artifactId>arquillian-bom</artifactId> 
<v...
@RunWith(Arquillian.class) 
public class MyTestClass { 
@Deployment 
public static Archive<?> createDeployment() { 
return...
<profile> 
<id>arq-jbossas-remote-7</id> 
<dependencies> 
<dependency> 
<groupId>org.jboss.as</groupId> 
<artifactId>jboss...
ShrinkWrap 
Deployment + Resolver + Descriptors
ShrinkWrap.create(JavaArchive.class) 
.addClasses(x) 
.addPackages(x.z) 
ShrinkWrap.create(WebArchive.class) 
.addAsLibrar...
Maven.resolver() 
.loadPomFromFile("pom.xml") 
.resolve("x:v", "x:y:1.0") 
.withTransitivity() 
.asFile();
Descriptors.create(WebAppDescriptor.class) 
.metadataComplete(true) 
.version("2.5") 
.createServlet() 
.servletName(EchoS...
Run modes
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
Upcoming SlideShare
Loading in …5
×

Testing the Enterprise layers, with Arquillian

2,523 views

Published on

Arquillian is an innovative and highly extensible testing platform for the JVM that enables developers to easily create automated integration, functional and acceptance tests for Java middleware, from Java EE and beyond.

For years we’ve been exploring how to layer and separate our code to test in isolation on the unit level. We’ve kept integration and functional testing as a big ball of mud; jumping straight from unit to full system testing. But can we apply some of the same lessons learned from unit to integration testing?


Speaker Bio:

Arquillian project lead, Aslak Knutsen, is a Senior Software Engineer at Red Hat where he is working on projects such as Arquillian and ShrinkWrap, one of the founders of the JBoss Testing initiative and a speaker at major industry conferences including JavaOne, Devoxx, Jazoon, JFokus, Geecon, JUDCon and JBoss World.

Published in: Software
  • Be the first to comment

Testing the Enterprise layers, with Arquillian

  1. 1. Greetings, Earthlings!
  2. 2. 1 Tests should be portable to any supported container
  3. 3. 2 Tests should be executable from both IDE and build tool
  4. 4. 3 The platform should extend/integrate existing test frameworks
  5. 5. The basics
  6. 6. Arquillian Core so you can rule the code, not the bugs!
  7. 7. Testing platform Middleware for your tests
  8. 8. Modular, Extensible, Flexible
  9. 9. Test Extension SPI for test runners
  10. 10. Test Runners JUnit · TestNG · Spock · JBehave · Cucumber · Thucydides
  11. 11. Container Extension SPI for runtime providers
  12. 12. Container Adapters WildFly · JBoss EAP · GlassFish · TomEE · Jetty · Tomcat · WebSphere · WebLogic · Spring · Weld · OSGi · Android · iOS
  13. 13. Container Test Extension Binds the two ⇒ In container testing
  14. 14. The basic Test Class
  15. 15. public class MyTestClass { private MyBean bean = new MyBeanStub(); @Test public void shouldBeAbleTo() { Assert.assertNotNull(bean); } }
  16. 16. @RunWith(Arquillian.class) public class MyTestClass { @Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(WebArchive.class) .addXYZ(...); } @Inject private MyBean bean; @Test public void shouldBeAbleTo() { Assert.assertNotNull(bean); } }
  17. 17. Demo
  18. 18. How does this all work?
  19. 19. Setup Maven, Gradle, Ant(+Ivy)
  20. 20. <dependencyManagement> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.1.5.Final</version> <scope>import</scope> <type>pom</type> </dependency> </dependencyManagement> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <scope>test</scope> </dependency>
  21. 21. @RunWith(Arquillian.class) public class MyTestClass { @Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(WebArchive.class) .addXYZ(...); } @Inject private MyBean bean; @Test public void shouldBeAbleTo() { Assert.assertNotNull(bean); } }
  22. 22. <profile> <id>arq-jbossas-remote-7</id> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-remote</artifactId> <version>${version.jbossas}</version> </dependency> </dependencies> </profile>
  23. 23. ShrinkWrap Deployment + Resolver + Descriptors
  24. 24. ShrinkWrap.create(JavaArchive.class) .addClasses(x) .addPackages(x.z) ShrinkWrap.create(WebArchive.class) .addAsLibraries(x) .addAsWebInfResource(x) .setWebXML(z) ShrinkWrap.create(EnterpriseArchive.class) .addAsModules(war, jar) .setApplicationXML(x)
  25. 25. Maven.resolver() .loadPomFromFile("pom.xml") .resolve("x:v", "x:y:1.0") .withTransitivity() .asFile();
  26. 26. Descriptors.create(WebAppDescriptor.class) .metadataComplete(true) .version("2.5") .createServlet() .servletName(EchoServlet.class.getSimpleName()) .servletClass(EchoServlet.class.getName()).up() .createServletMapping() .servletName(EchoServlet.class.getSimpleName()) .urlPattern(EchoServlet.URL_PATTERN).up() .exportAsString()
  27. 27. Run modes

×