GitHub - thuanpv/java_test_automation

Test Automation for Java Programs

Using this very simple buggy program (just ~10 lines of code), I show my students the limitations of manual testing and teach them how to apply test automation to improve the quality of programs written in Java. Specifically, I introduce to them the basic concepts in test automation including Fuzzing (my favourite topic :-)) and the tools/frameworks they can use such as JUnit, JUnit-QuickCheck, and JQF.

References

In addition to the great documentations on JUnit-QuickCheck and JQF repositories, I find the following wiki/blog posts/articles helpful

Install Docker

Please follow this instruction to install Docker on your machine.

Build a Docker image

First, you need to build a Docker image using the given Dockerfile. The Docker image has everything ready (e.g., Java JDK, JQF) for your experiments.

Run experiments inside a Docker container

Start a Docker container using the built image

docker run -it jta /bin/bash

Inside the Docker container, please follow the instructions below to test the example Triangle class.

First, go to examples folder

Then, compile the Triangle class and all test classes

javac -cp .:$(/jqf/scripts/classpath.sh) *.java

To test Triangle class manually, please run

To run JUnit test with the Triangle class

java -cp .:$(/jqf/scripts/classpath.sh) org.junit.runner.JUnitCore TriangleJUnitTest

To run JUnit-QuickCheck test

java -cp .:$(/jqf/scripts/classpath.sh) org.junit.runner.JUnitCore TriangleQCheckTest

To run fuzzing with JQF

/jqf/bin/jqf-zest -c .:$(/jqf/scripts/classpath.sh) TriangleJQFTest testInvalidTriangle

JQF automatically generates failure-triggering inputs and stores them in the folder fuzz-results/failures. To reproduce a failure, please run

/jqf/bin/jqf-repro TriangleJQFTest testInvalidTriangle fuzz-results/failures/id_000000

Enjoy Test Automation for Java!!!