Class: Oktest::Runner
Instance Method Summary collapse
-
#initialize(reporter) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
- #visit_scope(scope, depth, parent) ⇒ Object
- #visit_spec(spec, depth, parent) ⇒ Object
- #visit_topic(topic, depth, parent) ⇒ Object
Constructor Details
#initialize(reporter) ⇒ Runner
Returns a new instance of Runner.
1486 1487 1488 |
# File 'lib/oktest.rb', line 1486 def initialize(reporter) @reporter = reporter end |
Instance Method Details
#start ⇒ Object
1490 1491 1492 1493 1494 1495 1496 1497 |
# File 'lib/oktest.rb', line 1490 def start() #; [!xrisl] runs topics and specs. #; [!dth2c] clears toplvel scope list. @reporter.enter_all(self) visit_scope(THE_GLOBAL_SCOPE, -1, nil) THE_GLOBAL_SCOPE.clear_children() @reporter.exit_all(self) end |
#visit_scope(scope, depth, parent) ⇒ Object
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 |
# File 'lib/oktest.rb', line 1507 def visit_scope(scope, depth, parent) @reporter.enter_scope(scope) unless scope.equal?(THE_GLOBAL_SCOPE) #; [!5anr7] calls before_all and after_all blocks. call_before_all_block(scope) #; [!c5cw0] run specs and case_when in advance of specs and topics when SimpleReporter. if @reporter.order_policy() == :spec_first _spec_first(scope).each {|c| c.accept_visitor(self, depth+1, scope) } else scope.each_child {|c| c.accept_visitor(self, depth+1, scope) } end # call_after_all_block(scope) @reporter.exit_scope(scope) unless scope.equal?(THE_GLOBAL_SCOPE) end |
#visit_spec(spec, depth, parent) ⇒ Object
1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 |
# File 'lib/oktest.rb', line 1537 def visit_spec(spec, depth, parent) @reporter.enter_spec(spec, depth) #; [!u45di] runs spec block with context object which allows to call methods defined in topics. node = parent context = node.new_context_object() #; [!yagka] calls 'before' and 'after' blocks with context object as self. call_before_blocks(node, context) status = :PASS exc = nil #; [!yd24o] runs spec body, catching assertions or exceptions. begin params = Util.required_param_names_of_block(spec.block) values = params.nil? || params.empty? ? [] \ : get_fixture_values(params, node, spec, context) spec.run_block_in_context_object(context, *values) rescue NoMemoryError => exc; raise exc rescue SignalException => exc; raise exc rescue FAIL_EXCEPTION => exc; status = :FAIL rescue SKIP_EXCEPTION => exc; status = :SKIP rescue TODO_EXCEPTION => exc; status = :TODO rescue Exception => exc; status = :ERROR end #; [!68cnr] if TODO() called in spec... if context.__TODO #; [!6ol3p] changes PASS status to FAIL because test passed unexpectedly. if status == :PASS status = :FAIL exc = FAIL_EXCEPTION.new("spec should be failed (because not implemented yet), but passed unexpectedly.") #; [!6syw4] changes FAIL status to TODO because test failed expectedly. elsif status == :FAIL status = :TODO exc = TODO_EXCEPTION.new("not implemented yet") #; [!4aecm] changes also ERROR status to TODO because test failed expectedly. elsif status == :ERROR status = :TODO exc = TODO_EXCEPTION.new("#{exc.class} raised because not implemented yet") end location = context.__TODO exc.set_backtrace([location]) end #; [!dihkr] calls 'at_end' blocks, even when exception raised. begin call_at_end_blocks(context) #; [!76g7q] calls 'after' blocks even when exception raised. ensure call_after_blocks(node, context) end @reporter.exit_spec(spec, depth, status, exc, parent) end |
#visit_topic(topic, depth, parent) ⇒ Object
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
# File 'lib/oktest.rb', line 1522 def visit_topic(topic, depth, parent) @reporter.enter_topic(topic, depth) #; [!i3yfv] calls 'before_all' and 'after_all' blocks. call_before_all_block(topic) #; [!p3a5o] run specs and case_when in advance of specs and topics when SimpleReporter. if @reporter.order_policy() == :spec_first _spec_first(topic).each {|c| c.accept_visitor(self, depth+1, topic) } else topic.each_child {|c| c.accept_visitor(self, depth+1, topic) } end # call_after_all_block(topic) @reporter.exit_topic(topic, depth) end |