Skip to main content

Unit test automation tool

Project description

codecov

TestScribe for Python - unit test made easier

A tool to make python unit testing easier by automating the boring and repetitive parts.

Do you wish you don't have to write assertions before a test is run but just visually verify the result just like you would with testing a web page?

Do you write unit tests but don't like the overhead (create a file, name a function, write assertions...) or repetitiveness?

Have you experienced adjusting the mocking code multiple times before it allows the test to run? Do you have to refer to documentation from time to time to figure out how to mock or assert complex mock call parameters?

Do you wish to start a debugging session to understand a function better with as little overhead as possible?

Are you looking for an intuitive tool to help improve your code and coding skills?

This tool can help. It will

  • ask for inputs only and show you the test result.
  • take care of the repetitive and boring part of unit testing such as invoking the target function, creating files and functions with proper conventions, generating the assertions...
  • interactively prompt for the mock object's behavior in context with information such as the call stack.
  • generate complete working test code, which can serve as regression tests, examples and basis for further customization.
  • and more. Please see the complete documentation.

A simple example

Here is a very basic simple example to illustrate the basic usage. Suppose you have a function called is_prime in a file prime.py. It checks if the input number is a prime number. You can unit test the function using TestScribe without writing any boilerplate unit test code as follows:

$ testscribe create prime.py is_prime
...
Please provide the value for the parameter (n) of type: (int) []: 8
Calling is_prime(n=8)
***** Result:
type: <class 'bool'>
value:
False
***** Result end

Notice the only input you need to provide is the number 8.

You can run it multiple times with different inputs and inspect the displayed output. If the output is not correct, fix the production code and test again.

TestScribe automatically creates fully functional unit test files. You can use them to debug a test run or save them as regression tests or simply discard them.

The example above generates the following test file test_prime_g.py

from prime import is_prime
def test_is_prime():
    result = is_prime(n=8)
    assert result is False

This is the code you would likely have to write to unit test the same without TestScribe's help.

Below is a short demo video for the example above.

TestScribe simple demo

The benefits will become more significant for more complex scenarios. Here is an example involving mocks with an embedded demo video.

Easy to get started and setup

Adding testscribe to your development dependencies is all you need to start using the basic features. Most of the features should be self-explanatory to developers. Additional features such as launching the tool more easily only require simple setups.

Low risk to try

  • The tool doesn't modify the code you test in any way.
  • It doesn't introduce any dependency to your production code.
  • At any time, removing the tool won't break your existing production code or tests.
  • It's free and open source with the Apache 2.0 license.
  • You can always fall back to the traditional ways of testing for use cases the tool doesn't support yet. The tool won't get in your way.

Demo

You can find demos here. Feel free to download the demo project and try for yourself.

Frequently asked questions

Have questions before diving into details? You may find answers at the FAQ page

Documentation

It's capable of handling class instances, exceptions, class methods, mocking inputs, patching dependencies...

Please see the full documentation here.

You don't need to learn all the details at once. Refer to the documentation when your need for a specific feature arises. It's helpful to browse the document or the table of content to learn what it covers.

Copyright and license

Copyright 2022 Ruiguo (Ray) Yang

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

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

testscribe-0.0.3.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

testscribe-0.0.3-py3-none-any.whl (106.1 kB view details)

Uploaded Python 3

File details

Details for the file testscribe-0.0.3.tar.gz.

File metadata

  • Download URL: testscribe-0.0.3.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.3 Linux/5.15.0-56-generic

File hashes

Hashes for testscribe-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d08fb5f4363abbb626d7fcf01b7cb4e822f974fd8fe5b8d0444a5f415c5e543d
MD5 1e7cba890602bb31f3ed8577fc9b589e
BLAKE2b-256 54bdd92b005b17aba402b769a980bd6fdb723730a16c6f3728d831ff1e7a01e1

See more details on using hashes here.

File details

Details for the file testscribe-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: testscribe-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 106.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.3 Linux/5.15.0-56-generic

File hashes

Hashes for testscribe-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef01e15e3837a06eb92948b222e4718bd35e8546a7b08562160dd6cc65488097
MD5 a0457101ea2ee2ef8534a73357e914c7
BLAKE2b-256 2e8cb9550b6c2f2cf8ead509d1d67a8971660b722f7800dc5e33780800d16e2e

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