All Projects → reorx → deptest

reorx / deptest

Licence: other
dependent testing framework

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to deptest

Swift Code Metrics
Code metric analyzer for Swift projects.
Stars: ✭ 244 (+1526.67%)
Mutual labels:  dependency
kube-lineage
A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.
Stars: ✭ 238 (+1486.67%)
Mutual labels:  dependency
sbt-hackling
Prototype of the Libling concept. Libling is a way to add source dependencies to your sbt project.
Stars: ✭ 13 (-13.33%)
Mutual labels:  dependency
gochk
Static Dependency Analysis Tool for Go Files
Stars: ✭ 68 (+353.33%)
Mutual labels:  dependency
ScanTree
Scan a JS file tree to build an ordered and grouped dependency listing
Stars: ✭ 51 (+240%)
Mutual labels:  dependency
PackageProject.cmake
🏛️ Help other developers use your project. A CMake script for packaging C/C++ projects for simple project installation while employing best-practices for maximum compatibility.
Stars: ✭ 48 (+220%)
Mutual labels:  dependency
Innodependencyinstaller
Download and install any dependency such as .NET, Visual C++ or SQL Server during your application's installation!
Stars: ✭ 199 (+1226.67%)
Mutual labels:  dependency
elftree
ELF library dependency viewer
Stars: ✭ 40 (+166.67%)
Mutual labels:  dependency
ote
ote updates a packages' go.mod file with a comment next to all dependencies that are test dependencies; identifying them as such.
Stars: ✭ 25 (+66.67%)
Mutual labels:  dependency
DependencyInjector
Lightweight dependency injector
Stars: ✭ 30 (+100%)
Mutual labels:  dependency
py-dependency-install
A GitHub Action that installs Python package dependencies from a user-defined requirements.txt file path with optional pip, setuptools, and wheel installs/updates
Stars: ✭ 23 (+53.33%)
Mutual labels:  dependency
easy-ansible
基于Ansible的自动部署平台-Automatical Deployment Platform Based on Ansible。
Stars: ✭ 41 (+173.33%)
Mutual labels:  dependency
CNeptune
CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
Stars: ✭ 30 (+100%)
Mutual labels:  dependency
xcode-build-script-for-carthage
If you're using Carthage, you can easily set up Framework dependency in XCode through this script
Stars: ✭ 16 (+6.67%)
Mutual labels:  dependency
ts-depgraph
Generate a visually stunning dependency graph from your Angular or Typescript project
Stars: ✭ 24 (+60%)
Mutual labels:  dependency
Dont Break
Checks if the current version of your package would break dependent projects
Stars: ✭ 200 (+1233.33%)
Mutual labels:  dependency
ngx-print
🖨️ A plug n' play Angular (2++) library to print your stuff
Stars: ✭ 124 (+726.67%)
Mutual labels:  dependency
Zenject-2019
Dependency Injection Framework for Unity3D
Stars: ✭ 2,567 (+17013.33%)
Mutual labels:  dependency
dependent-issues
📦 A GitHub Action for marking issues as dependent on another
Stars: ✭ 83 (+453.33%)
Mutual labels:  dependency
Mimick.Fody
An integrated framework for dependency injection and aspect-oriented processing.
Stars: ✭ 15 (+0%)
Mutual labels:  dependency

Deptest

Deptest is a testing framework to handle situation when your need to control the execution order of the test units. Seriously, deptest does not follow the rules of unit testing, in other words, using this tool means you are thinking againest the philosophy of unit testing: “to isolate each part of the program and show that the individual parts are correct”.

But so what? Programming needs diversity, so does testing methodology. If the situation really exists, we should do something with it, that's why deptest is created, it could be considered as a different approach to organize your tests. Try it if you are stuck with unit testing, maybe it'll be helpful :)

Installation

pip install deptest

Usage

The core part of using deptest is to use depend_on decorator on your test functions. depend_on describes that a test function should be run if and only if its dependency function is OK. If dependency is FAILED, then the test function will not be executed and the status will be set to UNMET.

  1. Case 1, simple dependency

    from deptest import depend_on
    
    @depend_on('test_b')
    def test_a():
        print 'a, depend on a'
    
    def test_b():
        print 'b'

    This will ensure test_a run after test_b even though test_a is defined before test_b.

  2. Case 2, passing return value

    from deptest import depend_on
    
    @depend_on('test_b', with_return=True)
    def test_a(name):
        print 'a, depend on', name
    
    def test_b():
        print 'b'
        return 'b'

    With with_return argument set to True, the return value of test_b will be passed into test_a. By default return values of dependencies won't be passed.

  3. Case 3, complicated dependencies

    from deptest import depend_on
    
    @depend_on('test_c', with_return=True)
    @depend_on('test_b', with_return=True)
    def test_a(name1, name2):
        print 'a, depend on', name1, name2
        return 'a'
    
    @depend_on('test_d')
    def test_b():
        print 'b'
        return 'b'
    
    @depend_on('test_d')
    def test_c():
        print 'c'
        return 'c'
    
    def test_d():
        print 'd'
        return 'd'

    The dependent graph of the four functions will be:

    d
    | \
    b  c
    | /
    a
    

    Thus the execute sequence will be d, b, c, a or d, c, b, a, the results are fairly the same.

    $ deptest -s test/simple_test.py
    d
    → simple_test.test_d... OK
    b
    → simple_test.test_b... OK
    c
    → simple_test.test_c... OK
    a, depend on b c
    → simple_test.test_a... OK
    ______________________________________________________________________
    Ran 4 tests, OK 4, FAILED 0, UNMET 0
    

You can see some practical examples in examples/ folder, It's worth mentioning that http_api_test.py simulates an HTTP API testing case, which is mostly the reason why I develop this tool.

Note: to run http_api_test.py, you need HTTPretty installed.

Deptest provides a cli command also called deptest, it supports some common arguments of nosetests, like -s and --nocapture, see detail usage by deptest -h:

usage: deptest [-h] [-s] [--nologcapture] [--dry] [--debug] [PATH [PATH ...]]

positional arguments:
  PATH             files or dirs to scan

optional arguments:
  -h, --help       show this help message and exit
  -s, --nocapture  Don't capture stdout (any stdout output will be printed
                   immediately)
  --nologcapture   Don't capture logging
  --dry            Dry run, only show matched files
  --debug          Set logging level to debug for deptest logger

Screenshots

See it in action, run deptest examples:

Normal Mode

With --nologcapture argument:

With -s Stdout

TODO

  • support generator test function
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].