Skip to content

Report scenarios with unimplemented steps in cucumber json output - #833

Open
LucasLeao18 wants to merge 1 commit into
pytest-dev:masterfrom
LucasLeao18:fix-cucumberjson-first-step
Open

LucasLeao18 wants to merge 1 commit into
pytest-dev:masterfrom
LucasLeao18:fix-cucumberjson-first-step

Conversation

@LucasLeao18

Copy link
Copy Markdown

Problema

Quando o primeiro step de um cenário não tem definição implementada, o relatório cucumber JSON sai como []: o cenário é silenciosamente descartado. Se outro step (segundo em diante) estiver faltando, o cenário aparece normalmente. Reprodução mínima no corpo da issue #721.

Causa raiz: StepDefinitionNotFoundError é levantado em _execute_scenario antes de qualquer pytest_bdd_before_step, então nenhum step report é registrado. O hook pytest_bdd_step_func_lookup_error disparava sem nenhum handler de reporting, e LogBDDCucumberJSON.pytest_runtest_logreport ignora cenários com steps vazio.

Solução

  • reporting.step_func_lookup_error(): registra o step sem definição como falhado e finaliza o restante via ScenarioReport.fail(), o mesmo tratamento de qualquer outra falha no meio do cenário.
  • plugin.py: liga o hook pytest_bdd_step_func_lookup_error a esse handler (espelhando pytest_bdd_step_error).

Com isso, o cenário aparece no JSON com o step faltante marcado como failed (incluindo a mensagem Step definition is not found), independente de qual step esteja faltando.

Validação

  • Novo teste test_missing_first_step_definition em tests/feature/test_cucumber_json.py (falha antes do fix com [], passa depois).
  • tests/feature/test_cucumber_json.py: 4 passed.
  • Suíte completa: 137 passed; as 7 falhas restantes (test_feature_base_dir, test_generate, test_migrate) também falham num checkout limpo neste ambiente Windows, sem relação com a mudança.
  • ruff check, ruff format --check e mypy limpos nos arquivos alterados.

Referência

Fixes #721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Report not generating if first step is not implemented

1 participant