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

Install

pip install pyosmo

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

def test_smoke():
    osmo = Osmo(ExampleModel())
    osmo.test_end_condition = Length(10)
    osmo.test_suite_end_condition = Length(1)
    osmo.algorithm = RandomAlgorithm()
    osmo.generate()

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.5.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

pyosmo-0.0.5-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyosmo-0.0.5.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyosmo-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1301f283766d6dab0b76b3c182bd295d2087e7e6a7c26d8b7cce354dd792ec18
MD5 d93564e147eb86b83ff2bb90e8dc5cae
BLAKE2b-256 1784d8b48ed049ce1f6ebdf378681eeb90d66913ac5a82c912e651228e3a703e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyosmo-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyosmo-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ced57c8fc0e4d0a12a6fe3ec9b5fd48942aa55ce02c595aacafbf9f15729e2db
MD5 2724ccefac663702d0d4fd953f654ece
BLAKE2b-256 2ad5203c5e457f3d84c8478051fe1dbb4d238656fbeeb73ff56bdec822cfd90c

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