
Getting the band back together #
Now, let’s see if I can remember how the tests work. Thank goodness for run_tests.cmd
. Leaving aside the WIP connection tests, things seem to be in order.
First we’ll run the non-WIP, non-slow stuff against the normal database:
5 scenarios (5 passed)
25 steps (25 passed)
1m24.402s
And switch to the minimal test database and try again:
5 scenarios (3 failed, 2 passed)
25 steps (3 failed, 8 skipped, 14 passed)
1m55.317s
Trouble? Check the server console:
...
> 6/8/2016 11:42:31 PM: {SystemGo} Starting main game loop.
> 6/8/2016 11:42:53 PM: {Connection} Barbaloot (fe80::6d65:7756:6a1:af6f%17)
> 6/8/2016 11:42:53 PM: NPCs: [1] | Players: [1] | CPU: [??%] | Rnd: [41]
6/8/2016 11:43:06 PM: {SystemWarning} Item.CopyItemFromDictionary(30000) ITEM ID
does not exist.
> 6/8/2016 11:43:06 PM: {Exception} Exception Data: System.Collections.ListDicti
onaryInternal Source: DragonsSpine TargetSite: Void SetupNewCharacter(DragonsSpi
ne.Character)
> 6/8/2016 11:43:06 PM: {SystemGo} Starting main game loop.
> 6/8/2016 11:43:23 PM: NPCs: [1] | Players: [1] | CPU: [??%] | Rnd: [47]
6/8/2016 11:43:28 PM: {Connection} Barbaloot (fe80::6d65:7756:6a1:af6f%17)
> 6/8/2016 11:43:33 PM: {Connection} Barbaloot (fe80::6d65:7756:6a1:af6f%17)
>
...
Item 30000 is, of course, “Gold Coins”. Without it in the catalog, we’re throwing an exception when generating a new player. Once I resolve that, I get the same problem with item 31000, the spellbook for a new magic-using character. Add that in, and:
5 scenarios (5 passed)
25 steps (25 passed)
1m24.438s
Everyone deserves a fresh start #
I’ve frequently been an advocate of fully independent tests, making no assumptions about the environment, setting up and tearing down everything needed for the test. This is of particular benefit when it comes time to run tests in parallel, or in isolation to quickly iterate on a problem. So let’s add a hook to give each of these tests a freshly-started server with a clean copy of the minimal database:
|
|
Seems simple: kill the server if it’s running, reset the database (we’ve made changes to that .sql file to forcibly disconnect and remove the DB if it exists),
and start up a local copy of the server executable. We wait for the Log
table to include the final startup message (we don’t have to worry about history, since
we just recreated the DB). And this seems to work fine until we run the tests a second time and try to redirect the output:
K:\301days\Code\seitan-spin>bundle exec cucumber features --tags ~@WIP --tags ~@slow --format html --out cucumber.html --format pretty > cucumber.out
The process cannot access the file because it is being used by another process.
Since we’re using system
in the code to start up the server, it’s got a hold onto the STDOUT of the calling process,
and therefore a handle on the file it’s been redirected to.
But if we use %x
or similar, the call is never returning (even though we’re using start
). What should we do? We
could (and should) add an After
hook to kill the server, thereby freeing up its file handles. But there’s another
issue: we’re not actually getting the output of the server stored anywhere. Maybe we can find a way to address that
as well. Tomorrow.