Wiki
Show
Ignore:
Timestamp:
02/28/10 21:24:48 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Added -test-runner command line option to specify the method to invoke to run the unit tests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Cobra.Lang/Test.cobra

    r2292 r2295  
    11""" 
     2Cobra.Lang.Test contains a family of classes for running tests and reporting their results. 
     3 
     4Also, it is the library used by Cobra to run unit tests declared in the language, 
     5using the "test" keyword. 
     6 
    27EXAMPLE A 
    38 
     9    # Scans all assemblies for all Cobra-declared tests and runs them. 
    410    TestRunner(TextWriterListener(Console.out)).runAllTests 
    511 
     
    3339    tr.runTestsFor(System.Reflection.Assembly.getEntryAssembly, false) 
    3440    # false == do not follow dependencies 
     41 
     42EXAMPLE G 
     43 
     44    @args -test-runner:P.runTests 
     45     
     46    class P 
     47     
     48        def main 
     49            print 'Hello from main.' 
     50 
     51        def runTests is shared 
     52            # Due to the @args above, Cobra will invoke this method for running tests instead of 
     53            # Cobra.Lang.CobraCore.runAllTests. This allows you to customize the test runner, 
     54            # including setting parameters, adding listeners, using a custom subclass, etc.  
     55            # 
     56            # When customizing the test run, you will find it useful to read the interface to 
     57            # Cobra.Lang.Test, and possibly even the implementation. 
     58            # 
     59            # Alternatively, you can bypass Cobra.Lang.Test entirely and write whatever code 
     60            # you like here. 
     61            tr = Cobra.Lang.Test.TestRunner() 
     62            tr.runAllTests 
    3563 
    3664NOTES 
     
    4674    [ ] stack trace filtering could be interesting. more experience will be required to see if it's necessary. see 
    4775        http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/test-runner/junit/runner/BaseTestRunner.java&q=testrunner&d=2 
    48     [ ] more docs 
    49      
     76 
    5077    There are more TODOs in the code below. 
    5178""" 
     
    86113 
    87114        def runTestsFor(ass as Assembly, willFollowReferences as bool) 
     115            .runTestsFor(.collectTestsFor(ass, willFollowReferences)) 
     116     
     117        def runTestsFor(type as Type) 
     118            .runTestsFor(.collectTestsFor(type)) 
     119         
     120        def runTestsFor(suite as TestSuite) 
    88121            .makeTestRunListenerIfNeeded 
    89             suite = .collectTestsFor(ass, willFollowReferences) 
    90122            suite.run(.params, .listener to !) 
    91      
    92         def runTestsFor(type as Type) 
    93             .makeTestRunListenerIfNeeded 
    94             suite = .collectTestsFor(type) 
    95             suite.run(.params, .listener to !) 
    96      
     123             
    97124        def makeTestRunListenerIfNeeded 
    98125            ensure .listener