مخططات السيناريو وجداول البيانات
شغّل سيناريو Gherkin واحدًا باستخدام مجموعات بيانات متعددة عبر Scenario Outlines وجداول 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 واحدًا باستخدام مجموعات بيانات متعددة عبر Scenario Outlines وجداول 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مقدمة إلى BDD
- صياغة Gherkin وميزاتها
- تنفيذ تعريفات الخطوات
- مخططات السيناريو وجداول البيانات