Coder Social home page Coder Social logo

pyster's Introduction

Pyster

Build Status Code Style Coverage Status PyPI version

Pyster is a coverage-driven automatic unit test generator for Python projects.

Pre-request

Usage

# Stage 1: Init pyster config file
python3 -m pyster.init \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --path_runtime <runtime-analysis-code>
# Stage 2: Generate unit tests
python3 -m pyster.gen \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --user_tests <list-of-existing-test-files> \
  --timeout <timeout-limit> \
  --coverage <coverage-target>

# Run Stage 1 and Stage 2 together:
python3 -m pyster \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --path_runtime <runtime-analysis-code> \
  --user_tests <list-of-existing-test-files> \
  --timeout <timeout-limit> \
  --coverage <coverage-target>

Test

pytest tests

Sample execution

# Phase 1
python3 -m pyster.init --project_path tests/foobar --module_name foobar.foobar
# Phase 2
python3 -m pyster.gen --project_path tests/foobar --module_name foobar.foobar -t 1 -c 80

Pyster Logic

pyster-logic

The graph above is a high-level summary of Pyster's workflow.

Pyster contains two phases:

  • Phase 1: Type Analysis (init stage)
    • Input:
      • project_path: Absolute/relative path to project folder
      • module_name: Name of Python module for generating tests
      • path_runtime(optional): User-written Python file (e.g. existing test files) that makes use of functions in the selected module.
    • Output:
      • module_name.json: A configuration file containing all information used to randomly generate function calls. (All function signatures and their argument types, constructor of user-defined classes, etc.) This file can be further modified by user to provide more detailed type-related information.
  • Phase 2: Test Generation (gen stage)
    • Input:
      • timeout: Pyster terminates after timeout seconds.
      • coverage: Pyster terminates after test cases reach coverage code coverage rate.
      • user_tests(optional): If current module already has test suite, user_tests can be provided as a list of files so that Pyster will not generate tests covering lines already tested.
    • Output:
      • A runnable module_nameTest.py file containing all automatically generated unit tests as well as command-line output of coverage report.

pyster's People

Contributors

wenhaosu avatar jamzyu avatar

Stargazers

Eulia Wang avatar  avatar Ji Yishen avatar Emanuele Sabetta avatar Hiros avatar Pengyun Zhao avatar Zian Ke avatar

Watchers

 avatar

pyster's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.