Skip to main content

Resource oriented testing framework

Project description

https://travis-ci.org/gregoil/rotest.svg?branch=master https://ci.appveyor.com/api/projects/status/uy9grwc52wkpaaq9/branch/master?svg=true

Rotest is a resource oriented testing framework, for writing system or integration tests.

Rotest is based on Python’s unittest module and on the Django framework. It enables defining simple abstracted components in the system, called resources. The resources may be DUT (devices under test) or they may help the test process. The tests look very much like tests written using the builtin module unittest.

Why Use Rotest?

  • Allowing teams to share resources without interfering with one another.

  • Easily abstracting automated components in the system.

  • Lots of useful features: multiprocess, filtering tests, variety of output handlers (and the ability to create custom ones), and much more.

Examples

For a complete step-by-step explanation about the framework, you can read our documentation at Read The Docs. If you just want to see how it looks, read further.

For our example, let’s look at an example for a Calculator resource:

import os
import rpyc
from django.db import models
from rotest.management import base_resource
from rotest.management.models import resource_data


class CalculatorData(resource_data.ResourceData):
    class Meta:
        app_label = "resources"

    ip_address = models.IPAddressField()


class Calculator(base_resource.BaseResource):
    DATA_CLASS = CalculatorData

    PORT = 1357
    EXECUTABLE_PATH = os.path.join(os.path.expanduser("~"),
                                   "calc.py")

    def connect(self):
        self._rpyc = rpyc.classic.connect(self.data.ip_address,
                                          self.PORT)

    def calculate(self, expression):
        result = self._rpyc.modules.subprocess.check_output(
            ["python", self.EXECUTABLE_PATH, expression])
        return int(result.strip())

    def finalize(self):
        if self._rpyc is not None:
            self._rpyc.close()
            self._rpyc = None

The CalculatorData class is a standard Django model that exposes IP address of the calculator machine through the data attribute. Also, we’re using rpyc for automating the access to those machines. Except from that, it’s easy to notice how the connect method is making the connection to the machine, and how the finalize method is cleaning afterwards.

Now, an example for a test:

from rotest.core.runner import main
from rotest.core.case import TestCase


class SimpleCalculationTest(TestCase):
    calculator = Calculator()

    def test_simple_calculation(self):
        self.assertEqual(self.calculator.calculate("1+2"), 3)


if __name__ == "__main__":
    main(SimpleCalculationTest)

The test can include the setUp and tearDown methods of unittest as well, and it differs only in the request for resources.

Following, those are the options exposed when running the test:

$ python test.py --help
Usage: test.py [options]

Options:
  -h, --help            show this help message and exit
  -c CONFIG_PATH, --config-path=CONFIG_PATH
                        Tests' configuration file path
  -s, --save-state      Enable save state
  -d DELTA_ITERATIONS, --delta-iterations=DELTA_ITERATIONS
                        Enable run of unsuccessful tests only, enter the
                        number of times the failed tests should run
  -p PROCESSES, --processes=PROCESSES
                        Use multiprocess test runner
  -o OUTPUTS, --outputs=OUTPUTS
                        Output handlers separated by comma. Options: dots,
                        xml, full, remote, tree, excel, db, artifact,
                        signature, loginfo, logdebug, pretty
  -f FILTER, --filter=FILTER
                        Run only tests that match the filter expression, e.g
                        "Tag1* and not Tag13"
  -n RUN_NAME, --name=RUN_NAME
                        Assign run name
  -l, --list            Print the tests hierarchy and quit
  -F, --failfast        Stop the run on first failure
  -D, --debug           Enter ipdb debug mode upon any test exception
  -S, --skip-init       Skip initialization and validation of resources
  -r RESOURCES, --resources=RESOURCES
                        Specific resources to request by name

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotest-2.8.1.tar.gz (95.9 kB view details)

Uploaded Source

Built Distribution

rotest-2.8.1-py2.py3-none-any.whl (150.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rotest-2.8.1.tar.gz.

File metadata

  • Download URL: rotest-2.8.1.tar.gz
  • Upload date:
  • Size: 95.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rotest-2.8.1.tar.gz
Algorithm Hash digest
SHA256 28b709da3c6e3ee6d2343466f9ff92c67658afe1ca8d8c446f167cf5b253ca9a
MD5 93969dbc9bc6e0b0096b86722dcdba6e
BLAKE2b-256 1582a8b9d4c6acc614989f2590e94e4d6464238761f0807e6108948dbd63d12d

See more details on using hashes here.

File details

Details for the file rotest-2.8.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rotest-2.8.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c651a27a209cb0f22dc1986cf7fa04ab29cbf03fdce694aa1e88b7943b0a1c94
MD5 d40aebb1b9bca88c4966469457d19fd4
BLAKE2b-256 5b70f5f5a8e3f55f216ce95a89c53e35312be454a521de0d6e2436ae484a1869

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page