Cannot dynamically skip scenario during BeforeScenario hook
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
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
- Nessun Dockerfile né file Docker Compose
- Nessun 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 getgauge/gauge-java
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
getgauge/gauge-java#946 · 2 commenti ·
-
help wanted
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
getgauge/gauge-java#619 · 6 commenti · 3 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
getgauge/gauge-java#548 · 5 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
getgauge/gauge-java#466 ·
-
bug Windows
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
getgauge/gauge-java#429 · 1 commento ·
Tutte le issue di getgauge/gauge-java
Issue simili
-
agent:working bug follow-up lane:auto
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Sanne/incus-spawn#1765 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
opensearch-project/data-prepper#7219 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Update Java flags pageAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
PaperMC/docs#824 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno