Instructions running the RapidSMS automated tests

  1. It’s not currently possible to test RapidSMS outside of a project. So, if you haven’t already, follow the instructions on the Installation page to get setup with a project.
  2. RapidSMS requires django_nose to run its tests, so ensure that it’s installed and up to date. This may happen automatically if you use pip or easy_install to install RapidSMS.
pip install --upgrade django-nose
  1. In the file in your project directory, ensure your TEST_RUNNER is configured to use django_nose:
TEST_RUNNER = "django_nose.NoseTestSuiteRunner"
  1. Next, you can run all of the RapidSMS tests by typing:
./ test rapidsms

Note that this runs all of the RapidSMS tests. When using django_nose, the argument to ./ test is a package name, not an application name. This means Nose will find all tests under the "rapidsms" package.

Apart from standard python and django tests, we used to have an SMS testing framework, which is currently being updated to work with the latest version of RapidSMS.

Writing tests for your apps

You can write integration tests for your applications by using the TestScript framework. Just create a file in your app directory. Any TestCase that extends TestScript can take advantage of the assertInteraction method to test outgoing messages and their responses.

The string passed to assertInteraction is parsed into a script that is executed against the RapidSMS router. Each line which contains a > is interpreted as an incoming message from the number to the left of the >. Each line which contains a < represents a response from RapidSMS to the number to the left of the <.

Here is an example test case for the registration application:

import unittest
from rapidsms.tests.scripted import TestScript
class TestRegister(TestScript):
    def testRegister(self):
            8005551212 > register as someuser
            8005551212 < Thank you for registering, as someuser!

Testing (last edited 2010-09-06 10:47:46 by NicPottier)