Monday, 5 August 2013

Java: Test Coverage for Private Constructors

It is good practice to add private constructors to utility classes that are not thought to be instantiated. This is usually the case for final classes that only have static methods or provide constants (in the latter case I would suggest to use an interface).

Following this practice usually gives a bad surprise when looking at your Cobertura code-coverage report (or similar). The tool reports that the constructor is not covered - of course, because you cannot call it! This lowers your overall percentage for line-coverage and is a drawback when you otherwise try to achieve 100% line-coverage and also enforce this using mvn verify or similar methods.

Quality-Check contains a module called Quality-Test in its newest snapshot release. It includes a small utility class CoverageForPrivateConstructor which allows us to write a little JUnit-Test to provide line-coverage for the private constructor.

public void giveMeCoverageForMyPrivateConstructor() throws Exception {

This result in a code-coverage report with full test coverage also for the private constructor. Nice, isn't it?

Quality-Test and Blueprint

Quality-Check and Quality-Test version 1.3 have been released. As a major addtion, Quality-Test includes a new module for test-data generation called "Blueprint".

A complete introduction into the Blueprint module will be given here in a later post. For now, two small examples will show, how easy it is to construct objects (i.e. blueprint objects) for your unit-tests. We use the class description and a configuration as a blueprint to construct an actual object, which is ready to be used in the test-case.

final NameDTO name = Blueprint.random().with("gender", Gender.Male).construct(NameDTO.class); 

final Address address = Blueprint.def().with(String.class, "Default").with("zipCode", 12345L).construct(Address.class);

As you can see, Blueprint contains two default configurations, which either fill all attributes using default or random values. Basically, Blueprint will walk the object tree and fill all attributes with default values specified by the current configuration. Therefore, you won't get any NullPointerExceptions in your test-cases, as all attributes are filled with values. You have to define only those values on which your functional test-case actually depends. Everything else is handled by blueprint.

If you have questions regarding Blueprint, drop me a mail. A more lengthy introduction will follow soon. So far, best is you simply try it out.

Monday, 4 March 2013

Building Static PoDoFo 0.9.1 with MSVC 2012

Just found this nice article about building PoDoFo using Visual Studio:

As this is a frequently asked question, I though I post it here. It might be of use to some of you. Please note, so, PoDoFo as of 0.9.2 has a dependency on OpenSSL which is not mentioned in the article as it focuses on 0.9.1. We are currently discussing about replacing OpenSSL in favour of LibCrypto++.

Saturday, 23 February 2013

PoDoFo 0.9.2 Bug-Fix Release Available

PoDoFo 0.9.2 has been released today and is available for download at our download section. This release collects many bug fixes which were made over the last two years. The biggest addition is the new encryption support based on OpenSSL. Please note that OpenSSL is now a mandatory requirement.

Get downloads from

Saturday, 15 December 2012

KBarcode-kde4 port ready and released

KBarcode has been ported to KDE4/Qt4 by Fanda. Also some of the older bugs related to GUI have been fixed. It seems stable. The new version of KBarcode for KDE4/Qt4 has been renamed to KBarcode-kde4 so that users can have the old KBarcode for KDE3/Qt3 as well as the new KBarcode for KDE4/Qt4 installed on one system.

KBarcode-kde4 uses Akonadi. KCommand and related stuff has been ported to QUndoCommand and so on ... Spellchecking was ported to Sonnet but the new implementation of Sonnet in KBarcode-kde4 is odd and complicated so it will be deprecated and replaced in a future version.

KBarcode-kde4 is currently in a beta stage. It is not in Ubuntu or Debian repositories yet. At the moment (2012-12-14) only a deb package for amd64 architecture exists. Download the deb package kbarcode-kde4_3.0.0b2-1_amd64.deb from and follow instructions in to install it.

The source code can be found in the source tarball at or in the GIT repository at

Thank you very much for your work Fanda!

Wednesday, 12 September 2012

Quality-Check 0.10 released

We releases Quality-Check 0.10 today! The new release includes several new checks such as:
  • Check.instanceOf
  • Check.isNumber
  • Check.isNumeric
  • Check.notNaN

Most importantly you should check-out our enhanced webpage and especially our comparison, where we compare Check with other classes like org.springframework.util.Assert [1] or [2] or org.apache.commons.lang3.Validate [3].

Wednesday, 5 September 2012

Quality-Check for Java

André Rouél and I startet a new OpenSource project to avoid technical errors in Java applications: Quality-Check.

The goal of quality-check is to provide a small Java library for basic runtime code quality checks. It provides similar features to org.springframework.util.Assert or without the need to include big libraries or frameworks such as Spring or Guava. 
The package quality-check tries to replace these libraries and provide all the basic code quality checks.


 * Sets the given object if it is not null.
 * @throws IllegalArgumentException
 *         if the given argument is {@code null}
public void setObject(final Object object) {
    if (object != null) {
        throw new IllegalArgumentException("Argument 'object' must not be null.");
    this.object = object;

can be replaces by:

 * Sets the given object if it is not null.
public void setObject(final Object object) {
    this.object = Check.notNull(object);

It is now available in Maven Central so adding it to your project is as simple as putting these five lines into your pom.xml:

Please take also a look at our webpage or our project at GitHub.