Don't know how to get step code to run
@luke-hill ci sta già lavorando.
Dal 31/3/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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!
- Lingua principale
- Ruby
- Stelle
- 36
- Fork
- 48
- Merge medio
- 1h 54m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cucumber/cucumber-ruby-core
-
:bug: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 54/100
cucumber/cucumber-ruby-core#353 ·
-
Dependency DashboardAperta:no_good: wontfix
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
cucumber/cucumber-ruby-core#223 · 4 commenti ·
Tutte le issue di cucumber/cucumber-ruby-core
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
open-feature/ruby-sdk-contrib#340 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zold-io/wts.zold.io#651 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
erkamyaman/rust-anything#788 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
TheOdinProject/curriculum#31579 ·
I maintainer di solito rispondono entro 1 giorno