Skip to content

Testing example programs from the Checking Java Programs book and videos

Notifications You must be signed in to change notification settings


Repository files navigation

CJP-Examples: files for Checking Java Programs

I’ve been an advocate of advanced techniques and strong testing for most of my life as a software developer. This repository was first set up in 2007 (in CVS; moved to GitHub in 2015). It was originally built with Ant but has mostly been moved to Maven to simplify classpath. Classpath is also the reason I chose to split this repo into multiple projects, each an Eclipse project and a Maven-buildable project. Otherwise the classpath (and the Maven pom file) would become overly large.

This repo has been used as examples in:

  • The 2007 book Checking Java Programs;

  • The 2015 Video Series.

  • The forthcoming 2022 book Checking Java Programs.

Everything that is enabled as a module builds and passes its tests; the other modules do not pass at the moment: patches welcome; complaints, not so much. A few parts of this will indeed likely stay on Ant because one or two of the tools are only available as Ant plugins. While I do know about the maven-ant-plugin, it’s still just easier this way.

Note that at present the JDK level is set to 11 and will soon move to 17. Several modules don’t work on Java 11 because of the well-known restrictions on the Reflection API, but have been kludged around with the common workaround:

--add-opens java.base/java.lang=ALL-UNNAMED

There are several main directories:

  1. general is the catch-all containing various demos

  2. arquillian - arquillian is a server-side web component tester from JBoss

  3. coverage shows test coverage using Cobertura

  4. cucumber shows a bit of the tech used in Behaviour-Driven Development

  5. fbmining - Not a Maven module - post-processing of findbugs (now spotbugs) results

  6. jpf - not yet updated, contains Java PathFinder examples

  7. junit4 contains JUnit 4 examples

  8. junit5 contains JUnit 5 examples

  9. mockery contains mock-object (mockito and powermock)

  10. pmd contains some examples of PMD

  11. spock contains the Spock framework examples;

  12. spotbugs contains some examples of SpotBugs, the follow-on project to FindBugs

  13. static - static code analysis.

  14. web - some general web tests

  15. webtest-canoo - the Canoo web test framework

Of these, the current list of broken directories is: jpf, webtest-canoo. Plus, the arquillian folder has a race condition that only manifests on some platforms, and I’ve not yet tracked down if it’s in my code or the framework. And, the web folder has two tests disabled due to dependency issues. Sigh.

JPF: Java PathFinder

JavaPathFinder (JPF) is a really nice set of tools for examine state modelling of your Java code. It was created at NASA to verify the software used in the Mars Rover control program (not the embedded software in the device, but the ground-based controller software). Unfortunately, it has never been easy to get started with, nor has it made the leap from Ant to Maven. JPF seemed for a while like abandonware, but has been revived and is being modernized and even expanded.

Attention Users of the 2007 Book Version

The head commit of the master branch will be totally wrong for you if you try to follow the directions in the 2007 edition of the book. If you still want to follow a decade-old book you should only have to do git checkout a1ad04 after cloning the git repo.

When you install that version YOU WILL HAVE TO SET some Eclipse variables before it will work! This is expected. Emails asking why it doesn’t work out of the box when you haven’t read this file are probably going to be ignored, but you won’t know that if you didn’t read this file; that’s why it’s called a README file, I suppose. The details are in the 2007 book.


Thanks for reading/watching my book and/or my video series.

Ian Darwin

Java Testing for Developers, videocast Learning Path