Workshop 4: The Absolute Beginner’s Guide to JUnit in the Classroom
Wednesday Feb 29, 2012, 7:00pm-10:00pm, SIGCSE 2012, Raleigh, NC
Workshop #4 Abstract
Software testing has become popular in introductory courses, but many educators are unfamiliar with how to write software tests or how they might be used in the classroom. This workshop provides a practical introduction to JUnit for educators. JUnit is the Java testing framework that is most commonly used in the classroom. Participants will learn how to write and run JUnit test cases; how-to’s for common classroom uses (as a behavioral addition to an assignment specification, as part of manual grading, as part of automated grading, as a student- written activity, etc.); and common solutions to tricky classroom problems (testing standard input/output, randomness, main programs, assignments with lots of design freedom, assertions, and code that calls exit()).
SIGCSE 2012, Raleigh, NC
Wed Feb 29, 2012, 7:00pm-10:00pm
Intended audience
This workshop is intended for CS educators who want to write software tests or who want students to write tests for their own assignments. No prior experience with testing is required. Java fluency is expected. Basic knowledge of Eclipse is preferred, but not required. The examples presented will focus on CS1- and CS2-level Java assignments.
Pre-Workshop Preparation
Before you join us at the workshop, please read through the
following materials:
What is Test-driven Development?: Read
a brief overview of what TDD is.
What is JUnit?: A lightning overview of this
testing framework.
Set up your IDE for using
JUnit: Make sure you have a IDE installed
on your laptop with support for JUnit. We have instructions on how to do
so for BlueJ, jGrasp, NetBeans, and Eclipse. If you prefer to use the
command line, that's fine too. We will be using JUnit 3.x in our examples
(unless we hear a loud clamor for JUnit 4.x before the workshop!).
Make sure you have set up your own environment for using JUnit if
you want to try out some examples live during the workshop (not
necessary, but you're welcome to try out a few ideas live if you want).
JUnit Discussion Forum:
we have an on-line forum set up (use Facebook Connect to login, or
create an account) on the Web-CAT web
site for you to ask questions, discuss ideas, and share with each
other; feel free to use it before, during, and after the workshop.
Agenda
The goal is to give participants a solid introduction to writing JUnit tests. The workshop will be discussion-oriented and driven primarily by live examples. As examples are demonstrated, participants can ask questions as they arise and answers or alternatives can be illustrated in real time. In addition, hands-on “practice” activities will give participants a chance to work with live examples of the content. The agenda we will follow includes:
- A quick introduction to concepts of unit testing and an overview of JUnit and how it works, both on the command line and in typical IDEs (Eclipse and BlueJ); the difference between JUnit 3 and JUnit 4 (15 minutes).
- Discussion of the various strategies commonly used to employ unit testing in the classroom (15 minutes):
- public “acceptance tests” as part of an assignment specification
- private “reference tests” run by course staff during manual grading
- “reference tests” used for automated grading
- student-written tests for self-checking and/or grading
- and student-written tests of pre-existing code for developing debugging/testing skills
- Hands-on activity (and discussion): Practice writing JUnit tests for a classroom example (participants have two to choose from) (20 minutes).
- Using reference tests for automated grading, and the issues it raises. Writing software tests for student programs that have little or no constraints on student code structure (i.e., “open- ended” design problems, where students come up with the design themselves). Practical strategies for giving feedback (20 minutes).
- Hands-on activity (and discussion): Practice adding JUnit tests for an assignment. Participants pick the assignment (two to choose from) and pick the strategy they wish to employ (public tests to enhance the assignment spec, reference tests for grading, requiring students to write tests, etc.), and adapt the assignment and/or practice writing the corresponding tests. Participants exchange results and discuss. (20 minutes + break).
- An overview of common problems that instructors run into when writing software tests, and how they can be addressed (30 minutes).
- testing standard input/output behaviors
- testing programs that use random numbers
- testing main() programs instead of individual methods
- testing code with assertions
- testing code that calls exit()
- testing graphical user interfaces
- Hands-on activity (and discussion): Practice writing JUnit tests for a classroom example that uses stdio or random numbers (participants have two to choose from. (20 minutes plus 15- minute break.)
- Hands-on activity (and discussion): Practice writing JUnit tests for a simple GUI that has a button and some simple mouse interaction. (20 minutes)
- Wrap-up: open discussion of testing issues. Participants can discuss their own experiences, and ask questions about classroom experience or how specific assignment issues can best be tested or handled (10 minutes).