Zarysy scenariuszy i tabele danych
Uruchomią Państwo pojedynczy scenariusz Gherkin z wieloma zestawami danych, używając Scenario Outlines, tabel Examples i wbudowanych tabel danych.
Zarysy scenariuszy i tabele danych to bezpłatna lekcja Testing Mastery: JUnit, Mockito & Integration Tests na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Testing Mastery: JUnit, Mockito & Integration Tests, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Testing Mastery: JUnit, Mockito & Integration Tests zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Repeating Scenarios
Often you want to run the same behavior with different inputs. Copy-pasting a scenario per case is wasteful. Gherkin's Scenario Outline parameterizes one scenario over many examples.
Placeholders with Angle Brackets
In a Scenario Outline, values are placeholders written in angle brackets, filled in from an Examples table.
Scenario Outline: add numbers
Given I enter <a> and <b>
When I add them
Then the result is <sum>The Examples Table
The Examples keyword introduces a table of rows. Each row runs the outline once with those values.
Examples:
| a | b | sum |
| 2 | 3 | 5 |
| 0 | 0 | 0 |
| 5 | 7 | 12 |How It Expands
Cucumber expands the outline into one concrete scenario per Examples row, substituting the placeholders. Three rows means three test runs.
Step Definition Receives Values
The step definition uses capture groups, and each expanded row supplies its values.
@Given("I enter {int} and {int}")
public void enter(int a, int b) {
this.a = a; this.b = b;
}Data Tables vs Outlines
An Examples table multiplies the scenario. A data table passes a structured argument to a single step.
Given the following users
| name | role |
| Ada | admin |
| Bob | guest |Consuming a Data Table
The step receives the table, which you can convert into a list of maps or domain objects.
@Given("the following users")
public void users(DataTable table) {
List<Map<String,String>> rows =
table.asMaps();
}Choosing the Right Tool
Use a Scenario Outline when the whole flow repeats with varied inputs. Use a data table when one step needs a collection of structured data.
Keeping Examples Readable
Name columns clearly and keep each Examples table focused. Large unfocused tables hide which behavior you are actually specifying.
Multiple Examples Blocks
You can have several Examples blocks under one outline, each with a tag or comment, to group happy-path and edge cases.
Why It Matters
Parameterized scenarios keep features concise and make boundary testing explicit and reviewable by non-developers.
Quick Check
What does each row of an Examples table produce?
Recap
You learned data-driven Gherkin:
- Scenario Outline uses
<placeholders>and an Examples table - Each row runs the scenario once
- Data tables pass structured data to a single step
- Pick outlines for repeated flows, data tables for collections
Często zadawane pytania
Czy lekcja „Zarysy scenariuszy i tabele danych” jest bezpłatna?
Tak — pełny tekst „Zarysy scenariuszy i tabele danych” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Testing Mastery: JUnit, Mockito & Integration Tests, przejdź na CoddyKit PRO. Kurs Testing Mastery: JUnit, Mockito & Integration Tests zawiera 4 lekcji w sumie.
Co nauczysz się w „Zarysy scenariuszy i tabele danych”?
Uruchomią Państwo pojedynczy scenariusz Gherkin z wieloma zestawami danych, używając Scenario Outlines, tabel Examples i wbudowanych tabel danych. Ćwiczysz Testing Mastery: JUnit, Mockito & Integration Tests z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Testing Mastery: JUnit, Mockito & Integration Tests?
Nie wymagamy żadnego doświadczenia. Testing Mastery: JUnit, Mockito & Integration Tests w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Zarysy scenariuszy i tabele danych”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Testing Mastery: JUnit, Mockito & Integration Tests?
Tak. Każda lekcja Testing Mastery: JUnit, Mockito & Integration Tests zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Wprowadzenie do BDD
- Składnia i funkcje Gherkina
- Implementowanie definicji kroków
- Zarysy scenariuszy i tabele danych