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
using pip
pip install pyosmo
or using git clone
git clone git@github.com:OPpuolitaival/pyosmo.git
python -m pip install -e .
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
Built Distribution
File details
Details for the file pyosmo-0.1.2.tar.gz
.
File metadata
- Download URL: pyosmo-0.1.2.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64729268e81422e438f16d76aa63e0ef47baadde027609116159b0b4b2646d96 |
|
MD5 | e8d54c3747875530691ce9632a862908 |
|
BLAKE2b-256 | 925f6a6dba354ce8ce58f3effdf8970d4bb909bdf51466b79a01cc2c4c60ab63 |
File details
Details for the file pyosmo-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pyosmo-0.1.2-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05948319e02bd31c3848d4f1b553b4334065f4391c0e9b057352a2ce7283484 |
|
MD5 | 234ba8048bc70c892867e7eb1b0a3b37 |
|
BLAKE2b-256 | 27fb38289e64fee1a5f0c84e36875a300e395eaa817180e2e92f91d822d80a15 |