Skip to main content

Optimize test coverage by generating minimal test cases through pairwise parameter combinations

Project description

vedro-pairwise

PyPI Version License

vedro-pairwise is a Python package that extends the Vedro framework by enabling pairwise testing. Pairwise testing allows you to generate an optimal set of test cases, covering all possible pairs of parameter values. This approach reduces the number of test cases while ensuring good coverage, making it particularly useful for handling large sets of test combinations.

Installation

Install vedro-pairwise using pip:

$ pip install vedro-pairwise

Usage

To use vedro-pairwise, import the params_pairwise decorator from the package and apply it to your test scenarios in a vedro test suite.

Example

Here is an example of how to use vedro-pairwise to test a web page's rendering on different browsers, resolutions, and operating systems:

import vedro
from vedro_pairwise import params_pairwise

class Scenario(vedro.Scenario):
    subject = "Open /about page ({browser}, {resolution}, {os})"

    @params_pairwise(
        ["chrome", "firefox", "safari"],
        ["1024x720", "1920x1080", "800x600"],
        ["Windows", "Mac", "Linux"]
    )
    def __init__(self, browser, resolution, os):
        self.browser = browser
        self.resolution = resolution
        self.os = os

    def when_user_opens_page(self):
        self.page = open_about_page(self.browser, self.resolution, self.os)

    def then_it_should_show_main_content(self):
        assert self.page.main_content.is_visible()

Using pairwise testing for this set of parameters with three browsers, three resolutions, and three operating systems reduces the number of test cases while ensuring that every possible pair of values from different parameters is tested at least once. This minimizes the number of test cases below the full combination of NxMxO.

  • Browser: ["chrome", "firefox", "safari"] (3 values)
  • Resolution: ["1024x720", "1920x1080", "800x600"] (3 values)
  • Operating System: ["Windows", "Mac", "Linux"] (3 values)

With full combinatorial testing, the total number of test cases would be:

  • ( 3 x 3 x 3 = 27 ) test cases.

With pairwise testing, it is only necessary to ensure that every pair of parameters (Browser + Resolution, Browser + OS, Resolution + OS) is covered at least once. This reduces the number of required test cases.

Pairwise test cases:

Test Case Browser Resolution Operating System
1 chrome 1024x720 Windows
2 chrome 1920x1080 Mac
3 chrome 800x600 Linux
4 firefox 1024x720 Mac
5 firefox 1920x1080 Linux
6 firefox 800x600 Windows
7 safari 1024x720 Linux
8 safari 1920x1080 Windows
9 safari 800x600 Mac

Explanation:

  • Each browser is paired with each resolution and OS at least once.
  • Each resolution is paired with each browser and OS at least once.
  • Each OS is paired with each browser and resolution at least once.

This results in only 9 test cases, a significant reduction from the 27 required for full combinatorial testing.

Running Tests

Run the scenarios using the vedro command:

$ vedro run

The output will show the test cases executed, ensuring that all pairs of parameters are covered:

Scenarios
*
  Open /about page (chrome, 1024x720, Windows)
  Open /about page (firefox, 1920x1080, Windows)
  Open /about page (safari, 800x600, Windows)
  Open /about page (safari, 1920x1080, Mac)
  Open /about page (firefox, 1024x720, Mac)
  Open /about page (chrome, 800x600, Mac)
  Open /about page (chrome, 1920x1080, Linux)
  Open /about page (firefox, 800x600, Linux)
  Open /about page (safari, 1024x720, Linux)

# --seed a52af61f-01b8-4f3a-b44f-07af341b44ff
# 9 scenarios, 9 passed, 0 failed, 0 skipped (4.21s)

vedro-pairwise is a powerful tool for optimizing your test coverage without the overhead of exhaustive matrix testing. It balances test efficiency and coverage, making it an essential tool for managing complex test scenarios.

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

vedro_pairwise-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

vedro_pairwise-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file vedro_pairwise-0.1.0.tar.gz.

File metadata

  • Download URL: vedro_pairwise-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for vedro_pairwise-0.1.0.tar.gz
Algorithm Hash digest
SHA256 efb41000efe2f1ec00a522f2f940d3a2cfba4e0adf18e1940a4cb0f8537a73cc
MD5 25203285a7f94c9b9a975b08092b4b34
BLAKE2b-256 fa2a14d582cc28e268d99fee3c6647a4827eb0a33d77ce96dd4ee242377e7726

See more details on using hashes here.

File details

Details for the file vedro_pairwise-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vedro_pairwise-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for vedro_pairwise-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d177d32b07058ac0725b561f110d3bd5439bf2918c912d45443eeb634a47a2ce
MD5 dcd1d9eeeba2738b9e57872267eb8335
BLAKE2b-256 f8f2f272114e05d1df3378fbb8857e2aaa1976c8ca5e11bed92d4ad830db94d6

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