Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 5

In this assignment you will be writing unit tests in order to comprehensively test your code and beginning the design work for new features you would like to add to the game.

Part 1: Testing

Write unit tests for every method in your program that does not deal with user input or file input (e.g., no main method, no play method, no XML handler), does not purely produce output (like toString or inspectString), and is not purely a getter/setter with no other side effects. While we aren’t testing play directly, we want to test that each piece of functionality is working as it should (e.g., moving from one room to another, unlocking a door, etc). For each method you test, identify the normal case for the method, the edge cases, and cases where the method should fail. Be sure you test each of these! In addition, transform your method that makes sure rooms are connected from the last assignment into a JUnit test in this assignment.

Some tips: Start with the simplest methods with the least dependencies. For example, to test the method that unlocks a door, you need a door and a key. Test that the door only unlocks with the correct key, and does something reasonable if it’s already unlocked. Build up to testing more sophisticated functionality like the method handling moving the player from one room to another. If you’ve written a massive multi-hundred line play method, you should break it up so that pieces are testable (even if we aren’t testing that method itself.)

Part 2: Design

Perform the design work for three features you are thinking of adding to your project. For each of these, provide a description of the feature, classes, fields and methods you’ll need to add (and where you’ll need to add them if you’re adding to existing classes), and any other changes to the game you’ll need to make. Be sure to detail what each method, field, class, etc are doing. The idea is to have thought through the problem enough that when you go to implement it you know exactly what you need to do. You may not implement all three of these features in the future, but I’d like to see the design work for all three.