Module: Oktest
- Defined in:
- lib/oktest.rb
Defined Under Namespace
Modules: Color, SpecHelper, Util, UtilHelper Classes: AssertionFailed, AssertionObject, BaseReporter, CompactReporter, Config, Context, Filter, FixtureManager, FixtureNotFoundError, Item, JsonMatcher, LoopedDependencyError, MainApp, Matcher, Node, OktestError, PlainReporter, QuietReporter, Reporter, Runner, ScopeNode, SimpleReporter, SkipException, SpecLeaf, TestGenerator, TodoException, TopicNode, Traverser, VerboseReporter, Visitor
Constant Summary collapse
- VERSION =
'$Release: 1.2.1 $'.split()[1]
- FAIL_EXCEPTION =
FAIL_EXCEPTION = (defined?(MiniTest) ? MiniTest::Assertion :
defined?(Test::Unit) ? Test::Unit::AssertionFailedError : AssertionFailed)
AssertionFailed
- SKIP_EXCEPTION =
SkipException
- TODO_EXCEPTION =
TodoException
- THE_GLOBAL_SCOPE =
ScopeNode.new(nil, __FILE__)
- STATUSES =
[:PASS, :FAIL, :ERROR, :SKIP, :TODO]
- RUNNER_CLASS =
Runner
- THE_FIXTURE_MANAGER =
FixtureManager.new()
- REPORTER_CLASS =
VerboseReporter
- REPORTER_CLASSES =
{ 'verbose' => VerboseReporter, 'v' => VerboseReporter, 'simple' => SimpleReporter, 's' => SimpleReporter, 'compact' => CompactReporter, 'c' => CompactReporter, 'plain' => PlainReporter, 'p' => PlainReporter, 'quiet' => QuietReporter, 'q' => QuietReporter, }
- FILTER_CLASS =
Filter
Class Method Summary collapse
-
.__scope(scope, &block) ⇒ Object
:nodoc:.
-
.auto_run? ⇒ Boolean
:nodoc:.
- .filter(filter_obj) ⇒ Object
- .global_scope(&block) ⇒ Object
- .main(argv = nil) ⇒ Object
-
.on_exit ⇒ Object
:nodoc:.
- .run(reporter: nil, style: nil) ⇒ Object
- .scope(tag: nil, &block) ⇒ Object
Class Method Details
.__scope(scope, &block) ⇒ Object
:nodoc:
1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'lib/oktest.rb', line 1182 def self.__scope(scope, &block) #:nodoc: ! @_in_scope or raise OktestError, "scope() and global_scope() are not nestable." @_in_scope = true scope.run_block_in_context_class(&block) ensure @_in_scope = false end |
.auto_run? ⇒ Boolean
:nodoc:
2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 |
# File 'lib/oktest.rb', line 2830 def self.auto_run?() # :nodoc: #; [!7vm4d] returns false if error raised when loading test scripts. #; [!oae85] returns true if exit() called. exc = $! return false if exc && !exc.is_a?(SystemExit) #; [!rg5aw] returns false if Oktest.scope() never been called. return false unless THE_GLOBAL_SCOPE.has_child? #; [!0j3ek] returns true if Config.auto_run is enabled. return Config.auto_run end |
.filter(filter_obj) ⇒ Object
2437 2438 2439 |
# File 'lib/oktest.rb', line 2437 def self.filter(filter_obj) filter_obj.filter_children!(THE_GLOBAL_SCOPE) end |
.global_scope(&block) ⇒ Object
1153 1154 1155 1156 1157 1158 1159 |
# File 'lib/oktest.rb', line 1153 def self.global_scope(&block) #; [!flnpc] run block in the THE_GLOBAL_SCOPE object. #; [!pe0g2] raises error when nested called. self.__scope(THE_GLOBAL_SCOPE, &block) #; [!fcmt2] not create new scope object. return THE_GLOBAL_SCOPE end |
.main(argv = nil) ⇒ Object
2821 2822 2823 2824 |
# File 'lib/oktest.rb', line 2821 def self.main(argv=nil) status = MainApp.main(argv) exit(status) end |
.on_exit ⇒ Object
:nodoc:
2826 2827 2828 |
# File 'lib/oktest.rb', line 2826 def self.on_exit() # :nodoc: Oktest.main() if self.auto_run?() end |
.run(reporter: nil, style: nil) ⇒ Object
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 |
# File 'lib/oktest.rb', line 2085 def self.run(reporter: nil, style: nil) #; [!6xn3t] creates reporter object according to 'style:' keyword arg. klass = (style ? REPORTER_CLASSES[style] : REPORTER_CLASS) or raise ArgumentError, "#{style.inspect}: unknown style." reporter ||= klass.new #; [!mn451] run test cases. runner = RUNNER_CLASS.new(reporter) runner.start() ! THE_GLOBAL_SCOPE.has_child? or "** internal error" #; [!p52se] returns total number of failures and errors. counts = reporter.counts return counts[:FAIL] + counts[:ERROR] end |
.scope(tag: nil, &block) ⇒ Object
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
# File 'lib/oktest.rb', line 1161 def self.scope(tag: nil, &block) #; [!kem4y] detects test script filename. location = caller_locations(1, 1).first filename = location.path.to_s #; [!6ullm] changes test script filename from absolute path to relative path. if filename pwd = Dir.pwd() if filename.start_with?(pwd) filename = filename[pwd.length..-1].sub(/\A\//, '') elsif filename.start_with?('./') filename = filename[2..-1] end end #; [!vxoy1] creates new scope object. #; [!rsimc] adds scope object as child of THE_GLOBAL_SCOPE. scope = ScopeNode.new(THE_GLOBAL_SCOPE, filename, tag: tag) #; [!jmc4q] raises error when nested called. self.__scope(scope, &block) return scope end |