I just study Cucumber and notice that if two completely separate functions have two steps that are randomly worded identically, Cucumber offers only one definition of step for them. Does this mean that step definitions are global and are intended to be shared?
Example
Suppose a business analyst team writes specifications for a financial firm with a banking and brokerage unit. Further, suppose that two different people write functions for their respective departments to calculate transaction fees.
Bank guy writes:
Feature: Transaction Fees Scenario: Cutomer withdraws cash from an out-of-netwrok ATM Given that a customer has withdrawn cash from an out-of-netwrok ATM When I calculate the transaction fees Then I must include an out-of-netwrok ATM charge
Broker guy writes
Feature: Transaction Fees Scenario: Cutomer places a limit order Given that a customer has placed a limit order When I calculate the transaction fees Then I must include our standard limit-order charge
Note that the When clause is the same for both scenarios. Worse, both guys put this script in a file called transaction-fee.feature (in different directories, of course).
Cucumber gives the following recommendation for determining steps:
You can implement step definitions for undefined steps with these snippets: this.Given(/^that a customer has withdrawn cash from an out\-of\-netwrok ATM$/, function (callback) {
Please note that the when clause is only offered once.
- Does this mean that there should be only one step definition that needs to be entered in only one of the two step definition files?
- Are cucumbers associated with function files with similar step_definition files? In other words, does he link transaction fees with transaction fees .steps.js? If all step definitions are global, then I can mistakenly assume that the installation of files / directories is for the organization only and does not mean anything, as far as running around.
Thank you in advance for your time and clarification.
source share