2012-10-12 Testen mit Arquillian

Preview:

Citation preview

[mit uns...]

Testen mit ArquillianWürzburg, den 12. Oktober 2012

richtig testen

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

A Wo ist das Problem?

B Was leistet Arquillian?

C Grundlagen / Theorie

D Coding

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).

Wo ist das Problem?Benötigt es ein weiteres Testframework?

Oberflächentests mit Selenium funktioniert! (Integrationstest)

Alles SuperODER?

Wo ist das Problem?

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()); }}

Was leistet

?

“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]

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?

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)

Arquillian Grundlagen/Theorie

Architektur

Live Demo

… jetzt geht los!

16

Links

http://arquillian.org/

http://www.jboss.org/arquillian.html

18

Kontakt

nobisCumMatthias Reining[Senior Solutions Architect, Prokurist]Sedanstraße 2397082 Würzburg, Germany

[T] +49 (0) 931 / 7 96 67 – 0[F] +49 (0) 931 / 7 96 67 – 29[@] matthias.reining @ nobiscum.de[URL] www.nobiscum.de

Recommended