Regression Testing Assertions?

Hello!

I like the “test” command. I was wondering if there was a way to do an assertion inside of a test, and halt with an error if it fails. Specifically I would like to do something like:

test me with "go north / wear the socks / assert the player is wearing the socks / go east / assert the player is in the northeastern room"

…and have the interpreter halt and report which if any assertion failed. Does Inform7 currently have this capability?

The only way to stop the test command is to force the game to quit.

I made a very basic set of unit testing rules for Vorple, here: https://github.com/vorple/inform7/blob/6d0ebb4633a6d31b3abeff2c8cec7b5629560a24/tests/stories/unittest.i7#L514 You can easily use it also without Vorple if you remove the parts that do JavaScript evaluation and replace Vorple-specific text formatting with something from Basic Screen Effects for example. It doesn’t halt the execution if a test fails, but usually unit tests are allowed to run to the end even if some of them fail.

You’d then write assertion rules like this:

Start room is a room. Northern room is north of start room. Northeastern room is east of northern room.
The socks are in northern room. Socks are plural-named and wearable.

Instead of taking the socks:
	say "This makes the test fail."
	
Carry out unit testing "socks":
	whether or not the player is wearing the socks confirms "the player is wearing socks".

Carry out unit testing "northeastern room":
	whether or not the player is in northeastern room confirms "the player is in the northeastern room".

Test me with "go north / wear the socks / unittest socks / go east / unittest northeastern room".