0Pricing
Testing Mastery: JUnit, Mockito & Integration Tests · Урок

Контуры сценариев и таблицы данных

Запускайте один сценарий Gherkin с несколькими наборами данных с помощью контуров сценариев, таблиц Examples и встроенных таблиц данных.

«Контуры сценариев и таблицы данных» — бесплатный урок Testing Mastery: JUnit, Mockito & Integration Tests на CoddyKit. Это урок 4 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Testing Mastery: JUnit, Mockito & Integration Tests, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Testing Mastery: JUnit, Mockito & Integration Tests содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

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

Часто задаваемые вопросы

Урок «Контуры сценариев и таблицы данных» бесплатный?

Да — полный текст урока «Контуры сценариев и таблицы данных» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Testing Mastery: JUnit, Mockito & Integration Tests, подпишись на CoddyKit PRO. Курс Testing Mastery: JUnit, Mockito & Integration Tests содержит 4 уроков всего.

Чему я научусь в уроке «Контуры сценариев и таблицы данных»?

Запускайте один сценарий Gherkin с несколькими наборами данных с помощью контуров сценариев, таблиц Examples и встроенных таблиц данных. Ты практикуешь Testing Mastery: JUnit, Mockito & Integration Tests с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Testing Mastery: JUnit, Mockito & Integration Tests?

Предыдущий опыт не требуется. Testing Mastery: JUnit, Mockito & Integration Tests на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 4 из 4.

Сколько времени занимает урок «Контуры сценариев и таблицы данных»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Testing Mastery: JUnit, Mockito & Integration Tests?

Да. Каждый урок Testing Mastery: JUnit, Mockito & Integration Tests включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Введение в BDD
  2. Синтаксис и возможности Gherkin
  3. Реализация определений шагов
  4. Контуры сценариев и таблицы данных
← Назад к Testing Mastery: JUnit, Mockito & Integration Tests