Description
I've posted this question twice to the cucumber slack and no response, so asking here now. I was under the impression from the docs that I could use cucumber core to execute and report on tests.
I am trying to use cucumber core to make a test runner that can be executed from ruby code. I'm wanting to use my runner to run tests (with step code) concurrently while being able to fully control behavior and reporting.
My apologies if this is obvious but it appears to me now that the cucumber core api itself does not execute step code and I would like to know (or pointed to some examples/docs of) how to use cucumber core to accomplish the above.
I have made a runner referencing the docs here
My tests have some set to fail expect(1).to eql(2)
but when running with my test runner they all are marked as passed and it seems the step code is not run at all.
Here is the output from running my tests
Para cukes are running ✓
Tests will finish ✓
Para runner one is running--PASSED
Para cukes are running ✓
Tests will finish ✓
Para runner two is running--PASSED
Para cukes are running ✓
Tests will fail ✓
Para runner three is running--PASSED
Para cukes are running ✓
Tests will fail ✓
Para runner four is running--PASSED
The steps "Tests will fail" should fail and not be marked as pass (they fail when running with the CLI)
Here is my runner code
class CoreRunner
include Cucumber::Core
end
# Custom runner class using cucumber API
class ParaRunner
def run
scenario = 'features/test/para_runner/para_test_2.feature'
file_body = File.read(scenario)
feature = Cucumber::Core::Gherkin::Document.new(scenario, file_body)
CoreRunner.new.execute([feature], [ActivateSteps.new]) do |events|
events.on(:test_step_finished) do |event|
test_step = event.test_step
result = event.result
puts "#{test_step.text} #{result}"
end
events.on(:test_case_finished) do |event|
puts "#{event.test_case.name}--#{event.result.to_message.status}"
end
end
end
end
# Activator
class ActivateSteps < Cucumber::Core::Filter.new
def test_case(test_case)
test_steps = test_case.test_steps.map do |step|
activate(step)
end
test_case.with_steps(test_steps).describe_to(receiver)
end
def activate(step)
step.with_action {}
end
end
Thanks for all your help!