Automated testing of ChoiceScript games: Firefox + Selenium approach


#1

Salut!

I noticed people here like to test their 100000+ words games using clicking so I decided to write this short guide that will ease their pain. Of course, there’s an official way of ChoiceScript automated testing using Randomtest or Quicktest. My way is different and includes interactions with browser.

If you write something complex and unique (I am sure you do), you need to test your creation. Testing of text-based games is a trivial task for software developer. This article contains some advices for regular writers without programming experience and for users of ChoiceScript (I think it will work with Twine or Texture too).

I’ll show you how to create your automated tests for web-based interactive fiction and text adventures using special set of tools - Seleninum. I will cover the simplest way of writing tests with the help of Selenium plugin for Firefox.

You can achieve something like this (5 minutes effort):

The same effect can be achieved using standalone version of Selenium toolset, but it won’t be that easy :wink:

Install Selenium

0.) Install Firefox.

1.) Install Selenium IDE plugin. Go to addons.mozilla.org and press the ‘Add to Firefox’ button.

2.) After the installation process, check ‘tools’ menu: Selenium IDE field will appear.

3.) Press ‘Selenium IDE’ to launch the test suite.

#Write some tests for your game

I picked a game I found on this forum: Guenevere. This game implements different mechanics I can test (processing of user input, for example).

Fill the fields ‘Command’ and ‘Target’ in the Selenium IDE window:

You need to set ‘Command’ field to ‘open’ and ‘target’ to ‘link to your game’ like on the screenshot above. Now press the green arrow button to launch your first test.

Your first test checks the ability of your game to show its start page.

Let’s add some transitions. Press the record button (red button, top right corner). Selenium will start recording your actions. Time to play!

I am pressing random buttons, but you can plan your actions and record the most important or buggy way of playing your game. Press the red button again to stop recording.

Selenium is ready to reproduce recorded actions.

I switched the execution speed to ‘slow’ and pressed the green arrow button to perform my test:

#It’s alive!

I guess you understand that now you can actually create a test that goes through the entire game. You can write as many test cases as you want. You may notice a list of strange lines of text on the right side of the Selenium plugin window:

It’s the list where you can find every command executed by Selenium. You can add your commands by ‘recording’ them or you can add them manually.

Let’s add a command that checks the presence of a particular string on the screen:

Don’t forget to save your test:

I described the simplest way to automate testing process of your choice-based interactive fiction.

If you are brave enough to try this approach, don’t forget to leave a comment here with your feedback.

You can also find the full version of this guide in [my blog] (http://darkforestgame.blogspot.ru/2016/09/automated-testing-of-choice-based-text.html).

That’s all for now.


#2

Thank you for this. I don’t know how much people realize this but Selenium is actually a HUGE tool used in the industry, and even having it on your resume will probably get you some job offers. This is a great jumping off point since I know my way around CS but this seemed a little out of my reach.

To be honest, until this I didn’t even realize what Selenium was until your post. So again, thanks!


#3

Sounds similar to @CJW 's CSIDE only as a Firefox add on instead of a program.


#4

This blew me away, did not know this possible. Hmm I guess me could try it if I had time. Seems a fine tool to use.


#5

@CitizenShawn Thank you! You are right, this toolset is very powerful and is heavily used in the industry. I showed the simplest possible application :wink:

@Nocturnal_Stillness Well, yes and no. The tool itself is not connected with ChoiceScript. It’s a professional tool for testing and automating anything with web-pages and browsers (actually, it automates browsers). Plugin for Firefox implements 1% of its functionality (there is also standalone server, you can write tests in any programming language you want and so on).

@boredhypocrite Great, maybe someday this post will help you :wink:


#6

Yup and thanks for the step by step. It good and easy to follow :grin: