You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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!
The text was updated successfully, but these errors were encountered:
Are you able to get up something runnable ideally in the form of a branch against this repo or a fork that shows the failing test? I'll be able to look at it better that way as I don't have huge amounts of free time now
It looks like your step code "might" be the issue here. But I can't say for certainty as I've not used this area of the codebase much
I added a test that can be run with rspec spec/custom_runner_spec.rb because of the nature of the behavior though I cannot get it to fail.
Here is the step code
When('Some cukes are running') do
$stdout.puts('This step is running')
end
Then('This test will fail') do
$stdout.puts('This step should fail')
expect(2).to eql(3)
end
The console does output the scenarios so it seemed to find the scenarios but appears disconnected from the step code in my implementation.
The log outs are not printing and the test gets marked as passed. Because of this I'm not able to make failing test, but it demonstrates that the step code is not being run.
If you could see what I'm doing wrong here I would much appreciate it!
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
Thanks for all your help!
The text was updated successfully, but these errors were encountered: