Skip to main content

No project description provided

Project description

GitHub PyPI - Python Version

genut-py

genut-py is a semi-automatic unit test generator for Python

Description

Unit tests are crucial in software development.

However, writing unit tests is a laborious task and it often requires more efforts than implementing a new feature.

Before writing unit tests, we often know that our implementation certainly works correctly by executing a program with some actual inputs and observing its outputs.

Our program utilizes the execution to generate unit tests.

By adding decorators to target functions or methods, some inputs are selected from the execution based on its coverage, and then, unit tests in pytest format are generated automatically.

The generated tests is relatively easy to interpret as the inputs are "actual" data.

manual semi-automatic automatic
methods hand-craft retrieve from execution fuzz, smt-solver
tools genut-py UnitTestBot, Pynguin
interpretability high medium low
developper's burden high low low
coverage low medium high

Example

Generate Unit Tests of Functions

from genut_py import GenUT


@GenUT(line_trace=False)
def compare(x, y):
    if x < y or x == y:
        return 0
    if x > y:
        return 1
    assert False


for i in range(10):
    for j in range(10):
        compare(i, j)
from function import compare


class TestCompare:
    def test_compare_0(self):
        x = 0
        y = 0

        actual = compare(x,y)
        expected = 0

        assert actual == expected


    def test_compare_1(self):
        x = 0
        y = 1

        actual = compare(x,y)
        expected = 0

        assert actual == expected


    def test_compare_2(self):
        x = 1
        y = 0

        actual = compare(x,y)
        expected = 1

        assert actual == expected

Getting Started

Installation

pip install genut-py

Development

Format & Lint

# under /
make check

Generate Docs

# under /docs
poetry run make html

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

genut_py-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genut_py-0.1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file genut_py-0.1.3.tar.gz.

File metadata

  • Download URL: genut_py-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for genut_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7b0ec3eb0a37167212218ce2a673e56a8a2e56bc0b487fd5d0f3abd0a2db5ab0
MD5 74f1a7ca7c1e062e722339c4a77f9eaa
BLAKE2b-256 ce667b0bc769edce5731d778a6483cb8e5da055e4afd156256f75a4075bfbf08

See more details on using hashes here.

File details

Details for the file genut_py-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: genut_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for genut_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 472bf238f51e52c3ab7ce98cb5e032bbbfeca7de98e9af6c4aa62ee2c74b369e
MD5 3cec3f5bc8544b4a4bc845e977578462
BLAKE2b-256 3d0bc862ae38d51d7555d7e0dd4b28faaf43378a44a950a93863a67deb3e3301

See more details on using hashes here.

Supported by

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