Skip to main content

pyosmo - a model-based testing tool

Project description

pyosmo

A simple model-based testing (MBT) tool for python

pyosmo is python version of OSMO tester

Original OSMO tester can be found here: https://github.com/mukatee/osmo

Idea of model based testing is described in introduction

Example model

from pyosmo.osmo import Osmo


class ExampleModel:

    def __init__(self):
        print('starting')
        self._counter = 0

    def before_test(self):
        self._counter = 0

    def guard_decrease(self):
        return self._counter > 1

    def step_decrease(self):
        self._counter -= 1
        print("- {}".format(self._counter))

    def guard_increase(self):
        return self._counter < 100

    def step_increase(self):
        self._counter += 1
        print("+ {}".format(self._counter))


# Initialize Osmo with model
osmo = Osmo(ExampleModel())
# Generate tests
osmo.generate()

Select your approach

Offline model-based testing (MBT)

This means that the model will generate test cases which can be executed later using your existing test infrastructure. Checkout the example

Pros:

  • Maximum reuse of existing test harness
  • Osmo runs once and generated tests can be execute multiple times same way
  • Osmo can generate short tests for smoke and long tests for regression testing

Cons:

  • The model cannot evolve based on system under testing responses
  • Cannot test non-deterministic systems
  • Cannot run "infinite"

Online model-based testing

Online MBT means that when model steps are executed also real command are sent to the system and responses returned to the model.

Pros:

  • Model can be really smart because it may evolve based on the system
  • Enable non-deterministic systems testing
  • Test can take as long as needed

Cons:

  • Typically need more experiences of modelling
  • Cannot reuse existing test harness so easily

Use cases

Regression testing

from pyosmo.osmo import Osmo
from pyosmo.end_conditions import StepCoverage
from pyosmo.end_conditions import Length

# This ues same example model than defined above
osmo = Osmo(ExampleModel())
# Make sure that osmo go trough whole model in every test case
osmo.test_end_condition = StepCoverage(100)
# Do some test cases, which test do not take too long
osmo.test_suite_end_condition = Length(3)
# Give seed to make sure that test is same every time
osmo.seed = 333
# Run osmo
osmo.generate()

Long running test

import datetime
from pyosmo.osmo import Osmo
from pyosmo.end_conditions import Time

osmo = Osmo(ExampleModel())
# Run model for ten hours
osmo.test_end_condition = Time(int(datetime.timedelta(hours=10).total_seconds()))
osmo.test_suite_end_condition = Length(1)
osmo.generate()

Run with pytest

Performance testing

When system behaviour is modelled in online models you can use https://locust.io/ to run multiple models parallel for stress test purposes. It may need

Project details


Download files

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

Source Distribution

pyosmo-0.0.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

pyosmo-0.0.4-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pyosmo-0.0.4.tar.gz.

File metadata

  • Download URL: pyosmo-0.0.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyosmo-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b07d052825b3c366ebd9971ce6570178018913e851ab40205d85c2a25c0e7a1b
MD5 bf621f017c85c63d972464f204dae15a
BLAKE2b-256 5ca1230c4fa8f44bc746ac2d5546de428712645706818d3f486999ea54ec163b

See more details on using hashes here.

File details

Details for the file pyosmo-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyosmo-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyosmo-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d8bd78ca158dc02049ddd1df3a622f61e69491ff8afa1d60be7920f5b392a79e
MD5 b735e6061e7750379796ecfce52b18a4
BLAKE2b-256 8d6c23a4a3655eb9154202ae90d666993a6906c863512799215053f2d3639504

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