1. [mit uns...]
richtig testen
Testen mit Arquillian
Würzburg, den 12. Oktober 2012
2. Beschreibung der Veranstaltung:
Integrationstest mit Arquillian
"Arquillian is a revolutionary testing platform for enterprise Java."
Mit diesen Slogan wirbt Red Hat für Arquillian.
Die Schulung soll aufzeigen was hinter Arquillian steckt.
Im ersten Teil der Schulung werden die Grundlagen von Arquillian
vorgestellt. Im Anschluss werden diese mit Beispielen vertieft.
Zielgruppe: Entwickler / Tester
3. Agenda
3
A Wo ist das Problem?
B Was leistet Arquillian?
C Grundlagen / Theorie
D Coding
4. Wo ist das Problem?
Benötigt es ein weiteres Testframework?
jUnit existiert seit über 10 Jahren und leistet
seinen Dienst!
Mithilfe von Mocking Frameworks (bspw.
PowerMock & Mockito) lässt sich Testcode
komplett isolieren (Abhängigkeiten können
„gemockt“ werden).
5. Wo ist das Problem?
Benötigt es ein weiteres Testframework?
Oberflächentests mit Selenium funktioniert!
(Integrationstest)
…
Alles Super
ODER?
7. Wo ist das Problem?
@ApplicationPath("/rest")
public class RESTServiceApplication extends Application {
}
public class Resources {
@ConversationScoped
@ExtensionManaged
@Produces
@PersistenceUnit
EntityManagerFactory producerField;
@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return Logger.getLogger(injectionPoint.getMember()
.getDeclaringClass().getName());
}
}
10. “Arquillian is a revolutionary testing platform built on the
JVM that substantially reduces the effort required to write
and execute Java middleware integration and functional
tests. No more mocks. No more container lifecycle and
deployment hassles. Just real tests!”
[Quelle: http://jboss.org/arquillian.html]
“So you can rule your code. Not the bugs.“
[Quelle: http://arquillian.org]
11. Arquillian brings test execution to the target runtime so you don't have to
manage the runtime from the test (or project build). To invert this control,
Arquillian wraps a lifecycle around test execution that provides the following
services:
Manages the lifecycle of one or more containers
Bundles the test case, dependent classes and resources as
ShrinkWrap archives
Deploys the archives to the containers
Enriches the test case with dependency injection and other
declarative services
Executes the tests inside (or against) the containers
Returns the results to the test runner for reporting
Arquillian runs with Java 1.5 and above, integrates seamlessly with familiar
testing frameworks such as JUnit and TestNG and allows tests to be
launched using existing IDE, Ant and Maven test plugins.
[Quelle: http://jboss.org/arquillian.html]
12. Was leistet Arquillian?
12
Vernünftige Unit-Tests von gemanagten Klassen
Irreführende Mocks können entfallen
Möglichkeit Code mit verschiedenen Containern zu testen
Durch MavenDependencyResolver einfache Möglichkeit
„komplette“ Applikation zu testen / nicht nur Klasse
(Integrationtests)
Durch die Erweiterung Drone besteht die Möglichkeit
webbasierte Tests zu erstellen (Graphene, Selenium, Webdriver)