0Pricing
Testing Mastery: JUnit, Mockito & Integration Tests · Ders

Gherkin Sözdizimi ve Özellikler

İnsan tarafından okunabilir Gherkin sözdizimini kullanarak özellikleri, senaryoları ve Given-When-Then adımlarını tanımlamayı öğrenin.

Gherkin Sözdizimi ve Özellikler, CoddyKit'te ücretsiz bir Testing Mastery: JUnit, Mockito & Integration Tests dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Testing Mastery: JUnit, Mockito & Integration Tests öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Testing Mastery: JUnit, Mockito & Integration Tests kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Gherkin: Plain Language Tests

Gherkin is a plain-language parser used by Behavior-Driven Development (BDD) tools like Cucumber. It helps describe software behavior in a human-readable format.

This makes it easier for everyone—developers, testers, and business stakeholders—to understand and agree on what the software should do. Gherkin uses a specific set of keywords to structure these descriptions.

Defining a Feature

The Feature keyword is the starting point of any Gherkin document. It describes a high-level capability or a specific area of the application.

  • Think of it as the main goal or business requirement you are testing.
  • It should have a clear, concise title.
  • An optional description can follow, providing more context.
  • Each .feature file typically contains one Feature.

Feature Example in Action

Here’s how you define a Feature. Notice the optional description lines that add clarity, explaining the 'who', 'what', and 'why'.

Feature: User Login Functionality
  As a registered user
  I want to log in to my account
  So that I can access personalized content.

Describing Scenarios

Within a Feature, individual test cases are called Scenarios. A Scenario describes a single, concrete example of behavior.

For repetitive tests with different data, Scenario Outline is used. It runs the same steps multiple times, substituting values from an Examples table (which we'll cover in future lessons).

A Simple Scenario

A Scenario typically follows the "Given-When-Then" structure. It's a specific example of how the feature behaves under certain conditions.

Feature: User Login Functionality

  Scenario: Successful login with valid credentials
    Given the user is on the login page
    When the user enters "john@example.com" and "password123"
    And clicks the "Login" button
    Then the user should be redirected to the dashboard
    And a welcome message "Welcome, John!" should be displayed

Setting the Stage with `Given`

The Given keyword is used to describe the initial state or context of the system. It sets up the prerequisites for the scenario.

  • Think of it as the "precondition" for your test.
  • It should describe something that has already happened.
  • Example: Given the user is logged in or Given a product exists with price $10.

The Action with `When`

The When keyword describes the action or event that triggers the behavior under test. This is typically an interaction by the user or an external system.

  • It's the "trigger" for the behavior.
  • It should describe a single, observable action.
  • Example: When the user clicks the "Add to Cart" button or When the payment is processed.

Verifying Outcome with `Then`

The Then keyword describes the expected outcome or result after the When action. It's how you verify the system's behavior.

  • This is the "assertion" part of your test.
  • It should describe an observable change in the system.
  • Example: Then the item should be added to the cart or Then the order status should be "Completed".

Full Gherkin Scenario

Here's a complete Scenario showing Given, When, and Then working together. Notice how And can be used to extend any step for better readability.

Feature: Shopping Cart Management

  Scenario: Add item to empty cart
    Given the user is on the product page for "Laptop X"
    And the shopping cart is empty
    When the user clicks "Add to Cart"
    Then the shopping cart should contain "Laptop X"
    And the cart total should be $1200.00

Ordering Gherkin Steps

In Gherkin, steps follow a logical flow to describe a behavior. Arrange the keywords in the correct order for a typical scenario.

Gherkin Syntax Summary

You've learned the core elements of Gherkin syntax!

  • Feature defines a high-level capability.
  • Scenario describes a single example of behavior.
  • Given sets the initial context.
  • When describes the action or event.
  • Then verifies the expected outcome.
  • And and But are used to extend steps for readability.

This human-readable language bridges the gap between technical and non-technical team members, ensuring everyone understands the desired system behavior.

Sıkça Sorulan Sorular

“Gherkin Sözdizimi ve Özellikler” dersi ücretsiz mi?

Evet — “Gherkin Sözdizimi ve Özellikler” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Testing Mastery: JUnit, Mockito & Integration Tests kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Testing Mastery: JUnit, Mockito & Integration Tests kursu toplamda 4 dersten oluşur.

“Gherkin Sözdizimi ve Özellikler” dersinde ne öğreneceğim?

İnsan tarafından okunabilir Gherkin sözdizimini kullanarak özellikleri, senaryoları ve Given-When-Then adımlarını tanımlamayı öğrenin. Testing Mastery: JUnit, Mockito & Integration Tests ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Testing Mastery: JUnit, Mockito & Integration Tests öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Testing Mastery: JUnit, Mockito & Integration Tests, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“Gherkin Sözdizimi ve Özellikler” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Testing Mastery: JUnit, Mockito & Integration Tests dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Testing Mastery: JUnit, Mockito & Integration Tests dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. BDD’ye Giriş
  2. Gherkin Sözdizimi ve Özellikler
  3. Adım Tanımlarını Uygulama
  4. Senaryo Taslakları ve Veri Tabloları
← Testing Mastery: JUnit, Mockito & Integration Tests Sayfasına Dön