-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial progress to validate Gherkin files
- Loading branch information
Showing
13 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package info.jab.aoc; | ||
|
||
import io.cucumber.gherkin.GherkinParser; | ||
import io.cucumber.messages.types.Envelope; | ||
import io.cucumber.messages.types.GherkinDocument; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
public class GherkinValidatorTest { | ||
|
||
@Disabled | ||
@Test | ||
void validateAllGherkinFiles() throws IOException { | ||
// Encuentra todos los archivos .feature recursivamente | ||
try (Stream<Path> paths = Files.walk(Paths.get("src/main/gherkin"))) { | ||
paths.filter(Files::isRegularFile) | ||
.filter(path -> path.toString().endsWith(".feature")) | ||
.forEach(this::validateGherkinFile); | ||
} | ||
} | ||
|
||
private void validateGherkinFile(Path path) { | ||
try { | ||
GherkinParser parser = GherkinParser.builder().build(); | ||
|
||
// Validar el documento - si no hay excepciones, el archivo es válido | ||
Optional<GherkinDocument> doc = parser.parse(path) | ||
.filter(envelope -> envelope.getGherkinDocument() != null) | ||
.map(Envelope::getGherkinDocument) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalStateException("No se encontró GherkinDocument en " + path)); | ||
|
||
// Si llegamos aquí, el documento es válido | ||
System.out.println("Archivo válido: " + path); | ||
|
||
} catch (Exception e) { | ||
throw new AssertionError( | ||
"Error validando archivo: " + path + "\n" + e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters