Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Cannot dynamically skip scenario during BeforeScenario hook

Aperta
#926 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@serhatozdursun ci sta già lavorando.

Dal 21/7/2025.

  • #928 di @serhatozdursun — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
java
Ambito
testing

Direzione di ricerca

Start by tracing how @BeforeScenario hooks handle SkipScenarioException and how the runner reports a skipped scenario; the issue provides a minimal Java hook and spec that reproduce the behavior. Check the existing scenario hook and skip handling tests, then add or adapt a regression case for the skip tag. Done means the scenario is reported as skipped and its step does not run; an open linked pull request already addresses this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
Throwing SkipScenarioException in @BeforeScenario hook doesn't mark the scenario as skipped as expected.

To Reproduce
My goal is to use a custom skip tag to explicitly skip a scenario from a suite.

Here is a minimal example.

Using this implementation:

public class GaugeConfig {

    @BeforeScenario(tags = "skip")
    public void skipScenario() {
        System.out.println("skip " + context.getCurrentScenario().getName() + "...");
        throw new SkipScenarioException("Tagged to skip");
    }

    @Step("Print <message>")
    public void print(String message) {
        System.out.println("running " + message);
    }

}

And this spec:

# My spec

## Scenario 1
* Print "scenario 1"

## Scanario 2
Tags: skip
* Print "scenario 2"

Extract of pom.xml

    <dependencies>
        <dependency>
            <groupId>com.thoughtworks.gauge</groupId>
            <artifactId>gauge-java</artifactId>
            <version>0.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.17</version>
        </dependency>
    </dependencies>

Logs

C:\Gauge\bin\gauge.exe run --machine-readable --hide-suggestion --simple-console C:/test-gauge-java/specs/MySpec.spec
Testing started at 14:04 ...
[pool-1-thread-1] INFO org.reflections.Reflections - Reflections took 106 ms to scan 1 urls, producing 2 keys and 2 values
[pool-2-thread-1] INFO org.reflections.Reflections - Reflections took 3 ms to scan 1 urls, producing 0 keys and 0 values
running scenario 1
skip Scanario 2...
running scenario 2
Successfully generated html-report to => C:\test-gauge-java\reports\html-report\index.html

Specifications:	1 executed	1 passed	0 failed	0 skipped
Scenarios:	2 executed	2 passed	0 failed	0 skipped

Total time taken: 217ms

Process finished with exit code 0

Expected behavior
In my example the scenario 2 should be marked as skipped and not executed.

Versions:

  • Java 21
gauge -v

Gauge version: 1.6.18
Commit Hash: d6e10a4

Plugins
-------
flash (0.0.2)
html-report (4.3.3)
java (0.12.0)
json-report (0.5.0)
screenshot (0.3.2)
spectacle (0.2.1)
xml-report (0.5.2)
Lingua principale
Java
Stelle
99
Fork
51
Merge medio
1g 1h
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getgauge/gauge-java

Tutte le issue di getgauge/gauge-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.