PageSourceSearch

https://docs-production-katalon.netlify.app/assets/js/94c20eb4.7135a1be.js

js docs-production-katalon.netlify.app collected 2026-10-03 10:41:47 UTC 18,768 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkKatalon_Docs=self.webpackChunkKatalon_Docs||[]).push([[7556],{28453:(e,t,s)=>{s.d(t,{R:()=>r,x:()=>a});var n=s(96540);const i={},o=n.createContext(i);function r(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),n.createElement(o.Provider,{value:t},e.children)}},95421:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>l,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"get-started/sample-projects/behavior-driven-development/sample-bdd-cucumber-project-in-katalon-studio","title":"Sample BDD (Cucumber) project in Katalon Studio","description":"Introduction","source":"@site/docs/katalon-studio/get-started/sample-projects/behavior-driven-development/sample-bdd-cucumber-project-in-katalon-studio.md","sourceDirName":"get-started/sample-projects/behavior-driven-development","slug":"/get-started/sample-projects/behavior-driven-development/sample-bdd-cucumber-project-in-katalon-studio","permalink":"/katalon-studio/get-started/sample-projects/behavior-driven-development/sample-bdd-cucumber-project-in-katalon-studio","draft":false,"unlisted":false,"tags":[],"version":"current","lastUpdatedAt":1756189058000,"frontMatter":{"title":"Sample BDD (Cucumber) project in Katalon Studio"},"sidebar":"katalon-studio","previous":{"title":"Sample WebUI project with data-driven testing (Shopping Cart sample) in Katalon Studio","permalink":"/katalon-studio/get-started/sample-projects/data-driven-test/sample-webui-project-with-data-driven-testing-shopping-cart-sample-in-katalon-studio"},"next":{"title":"Sample API project in Katalon Studio","permalink":"/katalon-studio/get-started/sample-projects/api/sample-api-project-in-katalon-studio"}}');var i=s(74848),o=s(28453);const r={title:"Sample BDD (Cucumber) project in Katalon Studio"},a=void 0,l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Open the sample BDD test project",id:"open-the-sample-bdd-test-project",level:2},{value:"Trust dialog on first open",id:"trust-dialog-on-first-open",level:3},{value:"Overview of Sample BDD Project Components",id:"overview-of-sample-bdd-project-components",level:2},{value:"Profiles",id:"profiles",level:3},{value:"Feature Files",id:"feature-files",level:3},{value:"Example: Minus.feature",id:"example-minusfeature",level:4},{value:"Step definitions",id:"step-definitions",level:4},{value:"Executing a Feature File",id:"executing-a-feature-file",level:4},{value:"Custom Keywords",id:"custom-keywords",level:3},{value:"Test Listeners (Test Hooks)",id:"test-listeners-test-hooks",level:3},{value:"Test Case",id:"test-case",level:3},{value:"Test Suite",id:"test-suite",level:3},{value:"Execute selected test cases or test suites",id:"execute-selected-test-cases-or-test-suites",level:4},{value:"View BDD reports in Katalon Studio",id:"view-bdd-reports-in-katalon-studio",level:2}];function d(e){const t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)(t.p,{children:"Behavior-Driven Development (BDD) is a testing methodology that focuses on describing a product's behavior in plain English. Using Cucumber, a popular BDD framework, you can write test cases in Gherkin, a human-readable syntax."}),"\n",(0,i.jsx)(t.p,{children:"This document provides an overview of the components in a sample BDD (Cucumber) project using Katalon Studio."}),"\n",(0,i.jsx)(t.h2,{id:"open-the-sample-bdd-test-project",children:"Open the sample BDD test project"}),"\n",(0,i.jsxs)(t.p,{children:["The application under test (AUT) is a React-based Calculator, accessible at: ",(0,i.jsx)(t.a,{href:"https://katalon-studio-samples.github.io/calculator",children:"https://katalon-studio-samples.github.io/calculator"}),"."]}),"\n",(0,i.jsx)(t.p,{children:"To access the BDD sample project in Katalon Studio:"}),"\n",(0,i.jsxs)(t.p,{children:["Navigate to ",(0,i.jsx)(t.strong,{children:"File > New Sample Project > Sample BDD Cucumber Tests Project"}),".\n",(0,i.jsx)(t.img,{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Open-sample-project.png",alt:"Katalon Studio interface showing the navigation path: File > New Sample Project > Sample BDD Cucumber Tests Project."})]}),"\n",(0,i.jsxs)(t.p,{children:["Or, you can download the sample BDD test project from our GitHub repository: ",(0,i.jsx)(t.a,{href:"https://github.com/katalon-studio-samples/calculator-bdd-tests",children:"Sample BDD tests"}),"."]}),"\n",(0,i.jsx)(t.h3,{id:"trust-dialog-on-first-open",children:"Trust dialog on first open"}),"\n",(0,i.jsxs)(t.p,{children:["When you open a sample project for the first time, Katalon Studio will show a ",(0,i.jsx)(t.strong,{children:'"Trust and open this project"'})," dialog. This security prompt ensures you\u2019re aware of the source before opening and potentially executing harmful scripts."]}),"\n",(0,i.jsx)("img",{alt:" ",src:"https://tw-cdn.katalon.com/katalon-studio/manage-projects/trust-dialog-pop-up/trust-dialog-bdd-test.png",width:"500"}),"\n",(0,i.jsx)(t.p,{children:"In this dialog, you can:"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:"Review the project path."}),"\n",(0,i.jsx)(t.li,{children:"Decide whether to trust this project or all projects inside the parent folder."}),"\n"]}),"\n",(0,i.jsx)(t.admonition,{title:"Notes",type:"note",children:(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:"Trusting a parent folder also trusts all projects directly inside it, including the one you're opening."}),"\n",(0,i.jsx)(t.li,{children:"However, if this project contains subfolders with separate project files, those sub-projects won\u2019t be trusted automatically. You'll still see the trust dialog when opening them."}),"\n"]})}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:["Click ",(0,i.jsx)(t.strong,{children:"Trust Project"})," to continue, or ",(0,i.jsx)(t.strong,{children:"Don't Open"})," if you\u2019re unsure."]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"overview-of-sample-bdd-project-components",children:"Overview of Sample BDD Project Components"}),"\n",(0,i.jsx)(t.h3,{id:"profiles",children:"Profiles"}),"\n",(0,i.jsx)(t.p,{children:"In Katalon Studio, the execution profile is used to manage global variables that can be reused across different test cases in the project. The sample project includes a default execution profile that defines a key global variable:"}),"\n",(0,i.jsxs)(t.p,{children:["Go to ",(0,i.jsx)(t.strong,{children:"Profiles"})," > ",(0,i.jsx)(t.strong,{children:"default"})]}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Execution-profile.png",alt:"Katalon Studio interface showing the selection of the Profiles tab and the default profile."})}),"\n",(0,i.jsx)(t.p,{children:"The sample project includes a default execution profile that defines a key global variable:"}),"\n",(0,i.jsxs)(t.p,{children:["To learn more about execution profile, you can refer to this document: ",(0,i.jsx)(t.a,{href:"https://docs.katalon.com/katalon-studio/data-driven-testing/global-variables-and-execution-profile",children:"Execution profile"}),"."]}),"\n",(0,i.jsx)(t.h3,{id:"feature-files",children:"Feature Files"}),"\n",(0,i.jsxs)(t.p,{children:["Feature files define the test scenarios using ",(0,i.jsx)(t.strong,{children:"Gherkin syntax"}),". They act as a high-level blueprint for what the test is supposed to do.\nTo locate the sample feature files in Katalon Studio:"]}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Go to Include > features > operations."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Double-click any .feature file to open and view its contents."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Feature-files.png",alt:"Katalon Studio interface showing the list of feature files located in Include > features > operations",width:"350"}),"\n",(0,i.jsx)(t.h4,{id:"example-minusfeature",children:"Example: Minus.feature"}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.strong,{children:"Minus.feature"})," file defines a test scenario for subtraction operations using three Gherkin steps (Given, When, Then):"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-jsx",children:"Feature: Minus3\n\n  Scenario Outline: Minus\n    Given The Calculator page is loaded successfully\n    When <firstOperand> minus <secondOperand>\n    Then I get the result <result>\n\n    Examples: \n      | firstOperand | secondOperand | result |\n      | 10           | 20            | -10    |\n      | 123          | 456           | -333   |\n"})}),"\n",(0,i.jsx)(t.h4,{id:"step-definitions",children:"Step definitions"}),"\n",(0,i.jsxs)(t.p,{children:["Step definitions connect Gherkin steps to executable code, acting as the bridge between written scenarios and the actual test logic. Each step definition is a method that uses either a ",(0,i.jsx)(t.strong,{children:"regular expression"})," or a ",(0,i.jsx)(t.strong,{children:"Cucumber expression"})," (See the code snippet in Step 2 for examples of both) to map to specific Gherkin steps."]}),"\n",(0,i.jsx)(t.p,{children:"In this sample project, step definitions are organized into two separate packages located under Include > scripts > groovy:"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["Common Package: Contains ",(0,i.jsx)(t.code,{children:"Common.groovy"}),", which defines shared ",(0,i.jsx)(t.strong,{children:"Given"}
1)," and ",(0,i.jsx)(t.strong,{children:"Then"})," steps for all feature files."]}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://docs.katalon.com/d3227e60-51f3-11ee-bc71-0242c7a41fd4/KS-BDD-Common-step-definitions.png",alt:"Katalon Studio interface showing where Common.groovy file is located (Include > scripts > groovy > common)",width:"300"}),"\n",(0,i.jsxs)(t.ol,{start:"2",children:["\n",(0,i.jsx)(t.li,{children:"Operations Package: Contains four step definition files for Minus (-), Plus (+), Divide (\xf7), and Multiply (x), which define When steps for their corresponding feature files.\nFor example, the Minus.groovy file defines the When step in the Minus.feature file:"}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-operations-step-definitions.png",alt:"Katalon Studio interface showing where all feature files are located (Include > scripts > groovy > operations)",width:"300"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-jsx",children:"//All the required packages\nclass Minus \n\n\t//Regular expression\n\t@When(\"(\\\\\\\\d+) minus (\\\\\\\\d+)\")\n\tdef minus(long firstOperand, long secondOperand) {\n\t\tWebUI.callTestCase(findTestCase(\"Test Cases/common/Minus number\"), \n\t\t[ ('firstOperand') : firstOperand, ('secondOperand') : secondOperand ], \n\t\tFailureHandling.STOP_ON_FAILURE)\n\n\t//Or, Cucumber expression\n\t@When(\"{long} minus {long}\")\n\tdef minus(long firstOperand, long secondOperand) {\n\t\tWebUI.callTestCase(findTestCase(\"Test Cases/common/Minus number\"), \n\t\t[ ('firstOperand') : firstOperand, ('secondOperand') : secondOperand ], \n\t\tFailureHandling.STOP_ON_FAILURE)\n\t}\n}\n"})}),"\n",(0,i.jsx)(t.h4,{id:"executing-a-feature-file",children:"Executing a Feature File"}),"\n",(0,i.jsx)(t.p,{children:"In Katalon Studio, you can execute feature files directly without linking them to specific test cases, allowing for quick validation of behavior."}),"\n",(0,i.jsx)(t.p,{children:"To execute a feature file:"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Open the Test Explorer panel."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Navigate to Include > features > operations."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Right-click on the desired feature file (e.g., Minus.feature)."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Select Run Feature File from the context menu."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(t.h3,{id:"custom-keywords",children:"Custom Keywords"}),"\n",(0,i.jsx)(t.p,{children:"Custom keywords in Katalon Studio allow you to create reusable actions for your test cases."}),"\n",(0,i.jsxs)(t.p,{children:["In this sample project, the ",(0,i.jsx)(t.code,{children:"ClickNumber.clickNumber"})," keyword is designed to handle number input efficiently. It converts a given number into an integer and inputs it into the React Calculator."]}),"\n",(0,i.jsxs)(t.p,{children:["To view the custom keyword, go to ",(0,i.jsx)(t.strong,{children:"Keywords > sample > ClickNumber.groovy"})," in the Test Explorer panel."]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Cu
1stom-keyword.png",alt:"drawing",width:"300"}),"\n",(0,i.jsx)(t.h3,{id:"test-listeners-test-hooks",children:"Test Listeners (Test Hooks)"}),"\n",(0,i.jsx)(t.p,{children:"Test listeners (test hooks) are test steps created to define events before/after a test case/test suite."}),"\n",(0,i.jsxs)(t.p,{children:["To view the test listeners in this project, in the ",(0,i.jsx)(t.strong,{children:"Test Explorer"})," panel, go to the ",(0,i.jsx)(t.strong,{children:"Test Listeners"})," folder. We created two test listeners:"]}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:[(0,i.jsx)(t.code,{children:"TestListener"}),": This test listener opens Katalon Helper before every test suite execution."]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:[(0,i.jsx)(t.code,{children:"Listener"}),": This test listener closes the browser after every test case execution."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Test-listeners.png",alt:"drawing",width:"300"}),"\n",(0,i.jsx)(t.h3,{id:"test-case",children:"Test Case"}),"\n",(0,i.jsx)(t.p,{children:"Test case files, similar to feature files, perform mathematical operations using the React Calculator. They execute the steps defined in their corresponding feature files and validate the results."}),"\n",(0,i.jsx)(t.p,{children:"To view test cases in this sample project:"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Open the Test Explorer panel."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Navigate to ",(0,i.jsx)(t.strong,{children:"Test Cases"})," > ",(0,i.jsx)(t.strong,{children:"operations"}),"."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-operations-test-cases.png",alt:"drawing",width:"300"}),"\n",(0,i.jsxs)(t.p,{children:["The script below illustrates how a test case executes its corresponding feature file (e.g., linking ",(0,i.jsx)(t.code,{children:"Minus Test Case"})," to ",(0,i.jsx)(t.code,{children:"Minus Feature File"}),"):"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-jsx",children:"//All the required Java packages \n\nCucumberKW.runFeatureFile('Include/features/operations/Minus.feature')\n"})}),"\n",(0,i.jsx)(t.h3,{id:"test-suite",children:"Test Suite"}),"\n",(0,i.jsx)(t.p,{children:"A Test Suite groups multiple test cases for efficient execution, so that related tests run together and generate consolidated reports for analysis."}),"\n",(0,i.jsx)(t.p,{children:"Note: Test suites cannot execute feature files directly; you must create linked test cases first."}),"\n",(0,i.jsxs)(t.p,{children:["To view the sample test suite, navigate to ",(0,i.jsx)(t.strong,{children:"Test Suite > Verify Operations"})," in the Test Explorer panel."]}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-test-suite.png",alt:"A screenshot of the Verify Operations test suite"})}),"\n",(0,i.jsx)(t.h4,{id:"execute-selected-test-cases-or-test-suites",children:"Execute selected test cases or test suites"}),"\n",(0,i.jsx)(t.p,{children:"To execute a test case or a test suite in the sample project:"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Select the test case/test suite you want to execute."}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Click Run or press ",(0,i.jsx)(t.code,{children:"Ctrl + Shift + A"})," (",(0,i.jsx)(t.code,{children:"macOS: Cmd+Shift+A"}),"). You can choose different browsers to execute your test in the dropdown list next to Run."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)("img",{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/api-sample-prj/KS-API-Execution.png",alt:"drawing",width:"200"}),"\n",(0,i.jsxs)(t.ol,{start:"3",children:["\n",(0,i.jsxs)(t.li,{children:["View the test result in the ",(0,i.jsx)(t.strong,{children:"Log Viewer"})," tab."]}),"\n"]}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{src:"https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/docs/BDD-sample-prj/KS-BDD-Log-viewer.png",alt:"
1View test result in Log Viewer"})}),"\n",(0,i.jsx)(t.h2,{id:"view-bdd-reports-in-katalon-studio",children:"View BDD reports in Katalon Studio"}),"\n",(0,i.jsx)(t.p,{children:"Katalon Studio generates Cucumber Reports after executing a test suite, allowing you to review each test's status\u2014whether they passed, failed, encountered errors, or remain incomplete."}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsx)(t.li,{children:"To view your reports in different formats (HTML, CSV, XML):"}),"\n",(0,i.jsxs)(t.li,{children:["In the Test Explorer panel, right-click on your desired report folder.\nSelect ",(0,i.jsx)(t.strong,{children:"Open Containing Folder"})," from the context menu and navigate to the cucumber_report folder for HTML, CSV, or XML reports."]}),"\n",(0,i.jsx)(t.li,{children:"An HTML report will look like this:"}),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.