/cjp-examples

Examples from the Checking Java Programs book and videos

Primary LanguageJava

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.

Not everything builds or runs 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.

There are several main directories:

  1. general is the catch-all containing most demos for JUnit, PMD, Findbugs and JPF;

  2. spock contains the Spock examples;

  3. junit5 contains forward-looking statements about the next release of JUnit.

  4. pmd contains some examples of PMD

  5. findbugs contains some examples of FindBugs

  6. jpf - not maintained, contains JPF examples from 2007, using Ant.

The Sad Tale of JPF

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 - although a third-party project set up Maven repositories, these have become lost in the sands of time. There is a jpf-maven-plugin project which you can find and build, but since the repositories themselves are no longer available, it is probably pointless. "Look on my works, ye mighty, and despair…​"

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.

Contact

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

Ian Darwin

Java Testing for Developers, videocast Learning Path