• Stars
    star
    179
  • Rank 214,039 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Testplan, a multi-testing framework, because unit tests can only go so far..

ReadTheDocs TravisCI

Lifecycle Active

https://github.com/morganstanley/testplan/blob/main/doc/images/logo/testplan.png

a multi-testing framework

..because unit tests can only go so far..

Testplan is a Python package that can start a local live environment, setup mocks, connections to services and run tests against these. It provides:

  • MultiTest a feature extensive functional testing system with a rich set of assertions and report rendering logic.
  • Built-in inheritable drivers to create a local live environment.
  • Configurable, diverse and expandable test execution mechanism including parallel execution capability.
  • Test tagging for flexible filtering and selective execution as well as generation of multiple reports (for each tag combination).
  • Integration with other unit testing frameworks (like GTest).
  • Rich, unified reports (json/PDF/XML) and soon (HTML/UI).

Basic example

This is how a very basic Testplan application looks like.

import sys

from testplan import test_plan
from testplan.testing.multitest import MultiTest, testcase, testsuite

def multiply(numA, numB):
    return numA * numB


@testsuite
class BasicSuite(object):

    @testcase
    def basic_multiply(self, env, result):
        result.equal(multiply(2, 3), 6, description='Passing assertion')
        result.equal(multiply(2, 2), 5, description='Failing assertion')


@test_plan(name='Multiply')
def main(plan):
    test = MultiTest(name='MultiplyTest',
                     suites=[BasicSuite()])
    plan.add(test)


if __name__ == '__main__':
  sys.exit(not main())

Example execution:

$ python ./test_plan.py -v
        Passing assertion - Pass
          6 == 6
        Failing assertion - Fail
          File: .../test_plan.py
          Line: 18
          4 == 5
      [basic_multiply] -> Fail
    [BasicSuite] -> Fail
  [MultiplyTest] -> Fail
[Multiply] -> Fail

System integration testing example

Testing a server and a client communication.

import sys

from testplan import test_plan
from testplan.testing.multitest import MultiTest, testsuite, testcase
from testplan.testing.multitest.driver.tcp import TCPServer, TCPClient
from testplan.common.utils.context import context


@testsuite
class TCPTestsuite(object):
    """Testsuite for server client connection testcases."""

    def setup(self, env):
        env.server.accept_connection()

    @testcase
    def send_and_receive_msg(self, env, result):
        """Basic send and receive hello message testcase."""
        msg = env.client.cfg.name
        result.log('Client is sending his name: {}'.format(msg))
        bytes_sent = env.client.send_text(msg)

        received = env.server.receive_text(size=bytes_sent)
        result.equal(received, msg, 'Server received client name')

        response = 'Hello {}'.format(received)
        result.log('Server is responding: {}'.format(response))
        bytes_sent = env.server.send_text(response)

        received = env.client.receive_text(size=bytes_sent)
        result.equal(received, response, 'Client received response')


@test_plan(name='TCPConnections')
def main(plan):
    test = MultiTest(name='TCPConnectionsTest',
                     suites=[TCPTestsuite()],
                     environment=[
                         TCPServer(name='server'),
                         TCPClient(name='client',
                                   host=context('server', '{{host}}'),
                                   port=context('server', '{{port}}'))])
    plan.add(test)


if __name__ == '__main__':
    sys.exit(not main())

Example execution:

$ python ./test_plan.py -v
        Client is sending: client
        Server received - Pass
          client == client
        Server is responding: Hello client
        Client received - Pass
          Hello client == Hello client
      [send_and_receive_msg] -> Pass
    [TCPTestsuite] -> Pass
  [TCPConnectionsTest] -> Pass
[TCPConnections] -> Pass

A persistent and human readable test evidence PDF report:

$ python ./test_plan.py --pdf report.pdf
  [TCPConnectionsTest] -> Pass
[TCPConnections] -> Pass
PDF generated at report.pdf

https://github.com/morganstanley/testplan/blob/main/doc/images/pdf/readme_server_client.png

Documentation

For complete documentation that includes downloadable examples, visit this link.

Contribution

A step by step guide to contribute to Testplan framework can be found here.

License

License information here.

More Repositories

1

hobbes

A language and an embedded JIT compiler
C
1,162
star
2

binlog

A high performance C++ log library, producing structured binary logs
C++
593
star
3

modern-cpp-kafka

A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
C++
335
star
4

Xpedite

A non-sampling profiler purpose built to measure and optimize performance of C++ low latency/real time systems
Python
150
star
5

treadmill

lightweight, container-based compute fabric
Python
141
star
6

optimus-cirrus

Scala
94
star
7

desktopJS

desktopJS provides a common API across multiple HTML5 containers. By programming to a common API, applications can target multiple HTML5 containers without change.
TypeScript
76
star
8

ComposeUI

A .NET Core based, WebView2 using UI Container for hybrid web-desktop applications
C#
60
star
9

pyfixmsg

pyfixmsg is a library for parsing, manipulating and serialising FIX messages, primarily geared towards testing.
Python
54
star
10

winss

A supervision suite for Windows
C++
53
star
11

SilverKing

Scalable, high-throughput storage and coordination
Java
43
star
12

dotnet-please

CLI tool aims to streamline some repetitive tasks around Visual Studio projects and solutions
C#
24
star
13

MSML

Jupyter Notebook
23
star
14

ts-mocking-bird

A fully type safe mocking, call verification and import replacement library for jasmine and jest
TypeScript
19
star
15

flats

C++
18
star
16

needle

A lightweight flexible Dependency Injection library for use with TypeScript projects.
TypeScript
16
star
17

Crossroads

.NET Core commandline tool packager for developers
C#
11
star
18

message-broker

The MessageBroker is a typescript library for providing asynchronous communication throughout your app
TypeScript
11
star
19

cpx-training

Super simple sample programs for Circuit Playground Express
JavaScript
10
star
20

followapp-core

Analytics backed, cloud-based technology solution to remind and follow up with underprivileged mothers living in slums for their children's critical immunization
Java
9
star
21

venn-core

Perl
8
star
22

Plug-in-AppDynamics-Data-Source

AppDynamics Grafana Data Source Plugin
TypeScript
7
star
23

treadmill-aws

Treadmill AWS specific module
Python
7
star
24

treadmill-pid1

supporting project for treadmill
C
6
star
25

Saturn

Quality Assurance Automation Toolkit
Java
6
star
26

ML-for-Good-Hackathon

5
star
27

treadmill-bind

supporting project for treadmill
C
5
star
28

gradle-plugin-application

Morgan Stanley's Application plugin for Gradle allows you to package your Java-based applications for distribution, much like Gradle's built-in Application plugin does, but in a more standard and more flexible way.
Java
4
star
29

treadmill-tktfwd

Supporting project for treadmill
C++
3
star
30

zookeeper-authorizers

Java
3
star
31

releaseherald

releaseherald is a utility that can generate release notes. The only help it needs from developers is to collect meaningful news fragments in a directory, and apply consistent tags.
Python
3
star
32

jenkins-private-node

Jenkins plugin to support private CI nodes using job name patterns
Java
2
star
33

journal

Journal is a distributed state store intended to use with Zookeeper and NFS. Journal can be used with any asynchronous API Server to keep track of long running requests or automation tools.
Python
1
star
34

followapp-utils

Java
1
star
35

battleships-player-python

Python
1
star
36

proton

Hackathon game server
Scala
1
star
37

battleships-player-js

JavaScript
1
star
38

treadmill-runtime

C++
1
star
39

eslint-plugin-externalincludes

Suite of @html-eslint ESLint rules for working with external references such as script src and link hrefs
JavaScript
1
star
40

battleships

TypeScript
1
star
41

venn-cli

Perl
1
star
42

laf

Little Admin Framework
Python
1
star