Step 2: Creating the step method

Create a new step class. The class must:

  • Provide step methods for the new steps.
  • Inject ContextFactory

For step 2, you must create a CalendarSteps_Ext file to contain step methods for the new steps.

The following text is an example of a new CalendarSteps_Ext class.

package gw.cucumber.customer.steps.admin

uses com.google.inject.Inject
uses cucumber.api.java.en.Given
uses cucumber.api.java.en.Then
uses cucumber.api.java.en.When
uses gw.cucumber.context.api.ContextFactory
// additional uses statements may be needed

class  CalendarSteps_Ext {

   @Inject
   var _contextFactory : ContextFactory

   @Given ("^today is a \"([^\"]*)\"$")
   public function todayIsDayOfWeek(dayOfWeek : String) {
     _contextFactory.getCalendarContext_Ext().setTodaysDate(dayOfWeek)
  }

   @Given ("^tomorrow is the only holiday$")
   public function createHolidayForTomorrow() {
     _contextFactory.getCalendarContext_Ext().createHolidayForTomorrow()
  }

   @When ("^I create an activity using the \"([^\"]*)\" activity pattern$")
   public function iCreateActivityFromActivityPattern(activityPattern : String) {
     _contextFactory.getCalendarContext_Ext().createActivityFromActivityPattern(activityPattern)
  }

   @Then ("^there should be a \"([^\"]*)\" activity$")
   public function thereShouldBeAnActivity(activityPattern : String) {
     _contextFactory.getCalendarContext_Ext().verifyActivity(activityPattern)
  }

   @Then ("^the due date is \"(\\d+)\" days from today$")
   public function theDueDateIsXDaysFromToday(dueDateOffset :  int ) {
     _contextFactory.getCalendarContext_Ext().verifyTimeUntilActivityIsDue(dueDateOffset)
  }

}

For more information on creating step methods, see Creating step methods.