Unit testing Inform code?

7 views
Skip to first unread message

futab...@yahoo.com

unread,
Oct 16, 2005, 2:44:26 PM10/16/05
to
I've done a search for something like this, and am coming up empty, but
has anyone ever implemented a framework for writing unit tests for
Inform (or, more generally other IF) code? I can sort of see a hacky
workaround involving writing actual JUnit tests against a connection to
an actual interpreter, but I'd really like to be able to assert
directly on values without having to introduce new verbs to report
them, and ideally to write jMock-style mocks to isolate small pieces of
my code.

How do people write automated tests? Or does everyone just rely on
manual testing?

--
Susan Davis <s...@sue.net>

Andrew Plotkin

unread,
Oct 16, 2005, 3:13:32 PM10/16/05
to

The traditional automated test is to write a walkthrough of commands,
pump it into an interpreter, capture the transcript of the output, and
compare that to your last transcript.

(In this form, assertions are easy -- write an Inform function that
prints nothing if the argument is true, but prints "ALERT BOOGA BOOGA"
if the argument is false.)

This is more an end-to-end test than a unit test. But you can
introduce new (debugging) verbs to jump to a particular room and set
up a particular state, and then test commands from there. This lets
you write "walkthroughs" for small pieces of your game. I find that I
need such verbs anyway, in order to *write* the game, so this isn't an
additional complexity.

--Z

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
I'm still thinking about what to put in this space.

Ross Presser

unread,
Oct 17, 2005, 12:02:41 PM10/17/05
to
On Sun, 16 Oct 2005 19:13:32 +0000 (UTC), Andrew Plotkin wrote:

> (In this form, assertions are easy -- write an Inform function that
> prints nothing if the argument is true, but prints "ALERT BOOGA BOOGA"
> if the argument is false.)

I now have a very strong urge to download every Zarf game and use txd |
grep "ALERT BOOGA BOOGA".

Sam Denton

unread,
Oct 17, 2005, 8:17:49 PM10/17/05
to
futab...@yahoo.com wrote:

I use dfrotz, aka "dumb frotz", which is frotz compiled for a very dumb
terminal. It features special input modifiers to test things like timed
input, and the results are fairly easy to analyze.

Reply all
Reply to author
Forward
0 new messages