Java Test Code Generator

Sourceforge summary and download page for JTCG

Contents

Introduction

Yes, you guessed it, yet another Java test code generator!

This goes a little further than just generating the JUnit framework template and method stubs though. It will also generate code to apply different values to the method under test. Objects can also be defined in a global property file so that you can easily provide valid and invalid creations of your own objects.

What on earth prompted me to write my own generator? Well, I used a test code generator some time ago to create some test code. No big suprises there ... then I had to fill in the content which I found boring and repetitive. What was going on that writing test code was boring? It was because I was bombarding all the public methods in an API with valid and invalid values to create tests that would show up a number of errors that had caused problems inside a system due to incorrect input and/or configuration. These were quite straight forward errors to pick up on and, due to the reflection api, quite easy to generate code for so that you only have to fill in the actual test data.

So, I ended up writing a simple, straight forward generator. Now, it's nothing special to look at ... it is a work in progress. Direct lines of thought, no layers for the sake of having layers ... basically I'm saying that I just coded it without trying to follow any pattern, but creating (hopefully) plain, understandable Java code.

Features

ANT

Property File

Property file
The properties file is a Java property file and is a list of how to instantiate each object. Eg:

Future development

Come on! This can be taken further:


SourceForge.net Logo