Elasticsearch Integration Testing with Java

When building up search engines, indexing tons of data into a schema-less, distributed data store, Elasticsearch has always been a favourite tool of mine. In addition to its core features, it also offers tools and documentation for us developers when we need to write integration tests for our Elasticsearch powered Java applications. In the following tutorial I’d like to demonstrate how to implement a small sample application using Elasticsearch under the hood and how to write integration-tests with these tools for this application afterwards. ...

August 23, 2016 · 12 min · 2532 words · Micha Kops

Layout Testing with Galen, JUnit and Maven

Writing tests not only to verify the behaviour of a web site but also the correctness of its layout especially for responsive websites is not always easy. Luckily the Galen Framework eases the task of writing layout tests for us, offering a specialized domain-specific-language to write layout-specifications, it integrates well with Selenium Grid, Sauce Labs or BrowserStack, it offers an easy way to deal with different browser sizes and responsive designs and it generates nice, detailed test reports. ...

May 16, 2016 · 7 min · 1354 words · Micha Kops

Load Testing Web Applications with Gatling and Maven

I have written about other performance testing tools for web applications before. Nevertheless I’d like to demonstrate a library for load testing web applications named Gatling in combination with the build tool Maven. Gatling offers a nice Scala DSL, high performance using Akka, Netty and asynchronous IO and plug-ins for all modern build tools. In the following tutorial I’m going to show how to record simulations using an HTTP proxy, rewriting simulations in Scala and running and reporting simulations with Maven. ...

May 6, 2016 · 5 min · 1064 words · Micha Kops

Generating JUnit Tests with Java, EvoSuite and Maven

Generating test suites for existing code allows us to verify the behaviour of an application before we’re making changes to its code base or for regression testing. In the following short tutorial I’d like to demonstrate how to derive test suites from an existing Java application using EvoSuite and the EvoSuite Maven plug-in. EvoSuite offers some nice features like running in a sandbox to avoid dangerous operations, virtual file-system and network and optimizing of different coverage criteria. ...

February 28, 2016 · 5 min · 962 words · Micha Kops

Mocking HTTP Interaction with Java, JUnit and MockServer

When writing tests for our software components sometimes we need to mock external services based on the HTTP protocol, might it be a RESTful web-service, an XML-RPC call or a simple GET request to some web-server. In the following short tutorial I’d like to demonstrate how to create a mock HTTP server for testing and how to bootstrap and bind it to the life-cycle of a classical build-management tool like Maven. ...

January 5, 2016 · 4 min · 821 words · Micha Kops

Documenting RESTful Webservices in Swagger, AsciiDoc and Plain Text with Maven and the JAX-RS Analyzer

A variety of different tools exists to help us analyze RESTful web-services and create documentations for their APIs in different formats. In the following tutorial I’d like to demonstrate how to document an existing JAX-RS web-service in multiple formats like Swagger, AsciiDoc or Plain Text using Maven, the JAX-RS Analyzer and the JAX-RS Analyzer Maven Plugin. The JAX-RS Analyzer gathers its information not only by reflection like most other tools but also by bytecode analysis and therefore does not require us to add special annotations for documentation to our code. ...

June 16, 2015 · 6 min · 1119 words · Micha Kops

Mutation Testing with Pitest and Maven

Mutation testing makes an interesting addition to the classical test coverage metrics. They seed mutations (errors) into the code, run the project’s tests afterwards and if the tests fail, the mutation is killed – otherwise it lived and we have a possible indication of an issue with our tests. In the following short tutorial. I’d like to demonstrate how to setup mutation tests with the PIT/Pitest library and Maven and generate reports. ...

May 10, 2015 · 5 min · 917 words · Micha Kops

Performance Testing a Multiuser Web Application with JMeter and Maven

When there is the need to create load tests or performance tests for an application, Apache JMeter is a handy tool and set up with ease. In the following short tutorial I’d like to demonstrate how to configure JMeter to log into a Java EE web application with multiple users specified in a CSV file, how to generate some basic reports and how to integrate JMeter into a mavenized build using the JMeter Maven Plugin. ...

January 18, 2015 · 7 min · 1327 words · Micha Kops

BDD Testing with Cucumber, Java and JUnit

Whether behaviour-driven-development, specification by example or acceptance test driven development is the goal, the Cucumber framework eases our life when we need to establish a link between the non-technical, textual description for a new feature and the tests that prove that the application fulfils these requirements. In the following short tutorial I’d like to demonstrate how to add Cucumber to a Java project and how to write feature descriptions and test-cases for each step of these descriptions. ...

December 28, 2014 · 9 min · 1770 words · Micha Kops

Java EE: Setting up and Testing Form-Based JDBC Authentication with Arquillian and Maven

Especially when it comes to testing, setting up a decent environment for a secured Java EE web application isn’t always an easy thing to do. In the following tutorial I’d like to demonstrate how to create a secured web application using form-based authentication and a JDBC realm to fetch users and roles and how to run the application in an embedded container for testing and development. Additionally I’d like to show how to write and run integration tests to verify the security setup using a setup of Maven, Embedded GlassFish, Arquillian, jUnit and rest-assured. ...

December 21, 2014 · 14 min · 2822 words · Micha Kops