Changeset 2295 for cobra/trunk/Source/Cobra.Lang/Test.cobra
- Timestamp:
- 02/28/10 21:24:48 (2 years ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/Cobra.Lang/Test.cobra (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/Cobra.Lang/Test.cobra
r2292 r2295 1 1 """ 2 Cobra.Lang.Test contains a family of classes for running tests and reporting their results. 3 4 Also, it is the library used by Cobra to run unit tests declared in the language, 5 using the "test" keyword. 6 2 7 EXAMPLE A 3 8 9 # Scans all assemblies for all Cobra-declared tests and runs them. 4 10 TestRunner(TextWriterListener(Console.out)).runAllTests 5 11 … … 33 39 tr.runTestsFor(System.Reflection.Assembly.getEntryAssembly, false) 34 40 # false == do not follow dependencies 41 42 EXAMPLE 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 35 63 36 64 NOTES … … 46 74 [ ] stack trace filtering could be interesting. more experience will be required to see if it's necessary. see 47 75 http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/test-runner/junit/runner/BaseTestRunner.java&q=testrunner&d=2 48 [ ] more docs 49 76 50 77 There are more TODOs in the code below. 51 78 """ … … 86 113 87 114 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) 88 121 .makeTestRunListenerIfNeeded 89 suite = .collectTestsFor(ass, willFollowReferences)90 122 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 97 124 def makeTestRunListenerIfNeeded 98 125 ensure .listener



