0Pricing
Testing Mastery: JUnit, Mockito & Integration Tests · レッスン

シナリオアウトラインとデータテーブル

Scenario Outlines、Examplesテーブル、インラインデータテーブルを使い、1つのGherkinシナリオを複数のデータセットで実行します。

「シナリオアウトラインとデータテーブル」はCoddyKit上の無料Testing Mastery: JUnit, Mockito & Integration Testsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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時間対応のAIチューター)、Testing Mastery: JUnit, Mockito & Integration Testsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Testing Mastery: JUnit, Mockito & Integration Testsコースには全4レッスンが含まれています。

「シナリオアウトラインとデータテーブル」で何を学びますか?

Scenario Outlines、Examplesテーブル、インラインデータテーブルを使い、1つのGherkinシナリオを複数のデータセットで実行します。 ブラウザで直接実行するハンズオンコードでTesting Mastery: JUnit, Mockito & Integration Testsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Testing Mastery: JUnit, Mockito & Integration Testsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのTesting Mastery: JUnit, Mockito & Integration Testsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン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に戻る