Code Monkey home page Code Monkey logo

test-out's Introduction

test-out

Python class to provide useful logging, test run data and summary statistics for automated tests.

Features

  • Bookend your test code with test_start, test_end methods
  • This will start/stop test timers, provide average test duration
  • Track test results
  • Log test run and summary test results to console and log file

Usage

Example #1 - Simple Reporting

  • use test_start() & test_end() methods to bookend your test code
  • timer_test will kickoff automatically when test_start is called
  • see: Sample output
import time
from test_out import TestOut 

tout = TestOut()

for i in xrange(1, 6):
    tout.test_start(i)
    
    # FAKE TEST
    print 'running your test here...'
    # your result must be: 'PASS', 'FAIL' or 'ERROR'
    # generating random for this example:
    result = tout.get_result_random()
    comment = ' - This test is bogus, bro!'
    time.sleep(2)
    
    tout.test_end(result, comment)
    
tout.write_result_summary()

Example #2 - Custom reporting with service startup, etc.

  • pass param 'CUSTOM' to test_start: ` test_start
  • Note: timer_start() will NOT kick-off automatically
  • [do any test setup (start selenium server, etc.)]
  • timer_start()
  • [start your test]
  • [end your test]
  • timer_end()
  • write_result_summary() -see: Sample output
import time
from test_out import TestOut 

tout = TestOut()

for i in xrange(1, 6):
    tout.test_start(i, 'CUSTOM')
    tout.print_log('TEST SETUP'.format(i))
    print 'starting Selenium'
    print 'starting apache'
    print 'starting server XYZ'
    
    tout.print_log('START TEST'.format(i))
    tout.timer_start()

    # FAKE TEST
    print 'running your test here...'
    # your result must be: 'PASS', 'FAIL' or 'ERROR'
    # generating random for this example:
    result = tout.get_result_random()
    comment = '- This test is bogus, bro'
    time.sleep(2)
    tout.timer_end()
    tout.test_end(result, comment)

test.write_result_summary()

test-out's People

Contributors

rpappalax avatar

Watchers

James Cloos avatar

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.