JUnit is a set of Java Classes that allows you to do automated unit testing of Java Software. Automated unit testing is a "big deal" in many real-world Java software development shops these days, as some of our guest speakers this semester will tell you.
Last time, I asked the groups that had finished with A03, A04, A05 to "review" the submission of the "next" and "prev" groups (in the web ring), and post their comments to WebCT. If you haven't done that yet, that is step one for A06. Then you are ready for the next step.
If you like, you can divide up the work among the group members—have part of the group work on that, while the other part moves ahead with the items below.
In your group, gather 1 or 2 programmers to a laptop, and start familiarizing yourself with JUnit.
If you have two people, pick one person to "drive", and a second person to look on and watch, and guide the process.
First, read over the beginning of the article JUnit Test Infected: Programmers Love Writing Tests which is also available via a local link. Read just far enough that you start getting into code.
At that point, stop, back up a bit, and look at my article topics/java/junit/gettingStarted/gettingStartedWithJUnit.txt. This includes information on how to start working with JUnit on strauss (I'll try to get it installed on Porsche soon.) Do the steps needed to configure the strauss account of the person "driving" for JUnit.
Work through the "Money" example. The code is in topics/java/junit/gettingStarted/money on the course web site, which is also available directly on the strauss file system as the following directory:
/www/htdocs/CIS/474/pconrad/06S/topics/java/junit/gettingStarted/money
In that directory, among other things, you'll find a file called build.xml. If you are familiar with using Makefiles under C/C++, then this file is the same kind of thing. However, instead of using Make, it uses
a system called Ant. That's a whole other subject, but one you might as well start taking a look at as well. Ant helps you automate the process of compiling your Java web app.
So you should probably go ahead and read up on Ant, and configure your account for use with Ant also. Resources on Ant are in topics/java/deployment/ant
By the way, if you haven't read Chapter 2 in Better Faster Lighter Java, tonight would be a good time to do so. It puts all this stuff on JUnit and Ant into a context.
Say what?!!?! We haven't even written these classes yet? And you want us to write test cases?
Yup. That's exactly what I'm saying.
I know it may seem crazy at first, but that's what "test-driven development" is all about. The idea is that you write the test cases first, and then write the class. This has certain implications:
Start with your test data from your A05 web page.
If you want to know more, try typing just that set of keywords (i.e. stories, unit testing, pair-programming) into a search engine and see what comes up. Also, check out these ads from a recent issue of a trade magazine.
On your group web site, a link to a directory called A06 that contains Java code. In this directory, include a build.xml file for use with Ant that compiles your code, and runs tests on it. It's ok if for now the tests fail (i.e. because the body of your methods is all in stub form.)
Upcoming assignments will turn this all into a working web app—here's a preview: