Over a million developers have joined DZone.
Platinum Partner

Testing with Embed for Vaadin

· Java Zone

The Java Zone is brought to you in partnership with AppDynamics. Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems.

In order to execute integration tests of a web application, there are not so many tools available. One of such tools is JBoss Arquilian: it let you create an archive of your to-be-tested Java classes. Embed Vaadin does the same, but is specifically targeted at Vaadin applications and components!

Just select the component you want to test, and presto, it's wrapped in a dummy application and launched in an embedded Tomcat:

EmbedVaadin.forComponent(new FormAdvancedLayoutExample()).wait(false).start();

If you need to go beyond that and test the full application, that's also possible. The library takes care of instantiating the application class and all the underlying gory details.

EmbedVaadin.forApplication(EmbedApplication.class).wait(false).start();

Of course, there are configuration parameters. For example, you can choose the HTTP port (in order to avoid port conflict) and to launch a browser window. Presto, your integration test is ready to run!

EmbedVaadin.forApplication(EmbedApplication.class).withHttpPort(8888).wait(true).openBrowser(true).start();

For Maven users, the good news is that the add-on is readily provided as a Maven dependency:

<dependency>
    <groupId>com.bsb.common.vaadin</groupId>
    <artifactId>com.bsb.common.vaadin.embed</artifactId>
    <version>0.1</version>
    <scope>test</scope>
</dependency>

For those wishing to go further, a full-fledged example is available on Github.

Note that Embed Vaadin is available under the friendly Apache 2.0 license.

 

 

 

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:

Published at DZone with permission of Nicolas Frankel , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}