Lorin wrote:

> What in particular is your issue w/ Junit?  I've found it to be really
> convenient to work with. It's pretty straitforward, works well with Ant,
> etc.

When I used it (it might be better now) it required you to make a class to
do all your testing, rather than just adding static methods, which was a
rather unnecessary step.

Lately I've been using the following, written for Python (yeah, I know
there's a PyUnit, but I wrote this before that existed) -

import traceback
import sys
import types

def try_all(excludes = []):
    """
    tests all imported modules
    
    takes an optional list of module names and/or module objects to skip
over
    """
    failed = []
    for modulename, module in sys.modules.items():
        if modulename not in excludes and module not in excludes:
            try_module(module, modulename, failed)
    print_failed(failed)

def try_single(m):
    """
    tests a single module
    
    accepts either a module object or a module name in string form
    """
    if type(m) == types.StringType:
        modulename = m
        module = __import__(m)
    else:
        modulename = str(m)
        module = m
    failed = []
    try_module(module, modulename, failed)
    print_failed(failed)

def try_module(module, modulename, failed):
    if not hasattr(module, '__dict__'):
        return
    for n, func in module.__dict__.items():
        if not callable(func) or n[:4] != 'test':
            continue
        name = modulename + '.' + n
        try:
            print 'trying ' + name
            func()
            print 'passed ' + name
        except:
            traceback.print_exc()
            failed.append(name)
            print 'failed ' + name

def print_failed(failed):
    print
    if len(failed) == 0:
        print 'everything passed'
    else:
        print 'the following tests failed:'
        for i in failed:
            print i






_______________________________________________
Bits mailing list
[EMAIL PROTECTED]
http://www.sugoi.org/mailman/listinfo/bits

Reply via email to