Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:47:21+00:00 2026-06-02T16:47:21+00:00

Here’s what I have Feature: Register a new customer As a user I need

  • 0

Here’s what I have

Feature: Register a new customer
    As a user
    I need to be able to register myself
    so that I can place orders

Scenario: Register a new customer with Valid information
    Given I fill in valid customer information
    When I press submit
    Then I should be notified that I'm registered

Scenario: Register a new customer with Invalid information
    Given I fill in invalid customer information
    When I press submit
    Then I should be notified it was invalid

The problem is that I’m repeating the When twice, but I don’t see a way around this, what I need to do is figure out how you would set this up correctly with 2 scenarios or am I not looking at this correctly?

Here are the Step definitions, but they don’t seem right to me because I have to have all of these in the same Steps class for it to run. Doesn’t read correctly in my opinion. When I break these 2 apart and put them in their own step class I get the erorr:

binding error: Ambiguous step definitions found for step 'When I press submit':



[Binding]
   public class RegisterAValidCustomerSteps
   {
      private RegisterCustomerViewModel _registerCustomerVm;

      [Given(@"I fill in valid customer information")]
      public void GivenIFillInValidCustomerInformation()
      {
         // use the ViewModel to represent the User interacting with the View
         _registerCustomerVm = new RegisterCustomerViewModel();
         _registerCustomerVm.FirstName = "Mark";
         _registerCustomerVm.LastName = "W";
         _registerCustomerVm.Email = "mark@whatever.com";
      }

      [Given(@"I fill in invalid customer information")]
      public void GivenIFillInInvalidCustomerInformation()
      {
         // simulate possible invalid name by missing the Last Name
         _registerCustomerVm = new RegisterCustomerViewModel();
         _registerCustomerVm.FirstName = "Mark";
         _registerCustomerVm.Email = "markl@whatever.com";
      }

      [When(@"I press submit")]
      public void WhenIPressSubmit()
      {
         _registerCustomerVm.Submit();
      }

      [Then(@"I should be notified that I'm registered")]
      public void ThenIShouldBeAbleToPlaceOrders()
      {
         _registerCustomerVm.MessageText.ShouldBe("Success!  Check your inbox for confirmation");
      }

      [Then(@"I should be notified it was invalid")]
      public void ThenIShouldBeNotifiedItWasInvalid()
      {
         _registerCustomerVm.MessageText.ShouldBe("Failure!  Last Name can't be blank.");
      }
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:47:23+00:00Added an answer on June 2, 2026 at 4:47 pm

    You have different contexts in these scenarios. When same event occurs in different contexts you have different outcomes. Thats what you are describing by these scenarios.

    So, there is no problem with repeating When step. You actually do same thing twice. Just reuse it. If in some scenarios you will have same contexts, but different events, then you will have repeating Given steps. Same with outcomes.

    Consider these scenarios for bowling game:

    Scenario: Gutter game
        Given a new bowling game
        When all balls landing in gutter
        Then total score should be 0
    
    Scenario: All strikes
        Given a new bowling game
        When all rolls are strikes
        Then total score should be 300
    

    These scenarios have same context Given a new bowling game. You should write same code to setup scene for each scenario. So, you have only one implementation of this step, which is reused by both scenarios.

    [Given(@"a new bowling game")]
    public void GivenANewBowlingGame()
    {
        _game = new Game();
    }
    

    Also you can use one step definition to verify your outcomes (because they are actually same – verifying total score):

    [Then(@"my total score should be (\d+)")]
    public void ThenMyTotalScoreShouldBe(int score)
    {
        Assert.AreEqual(score, _game.Score);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation, i want to have a user that can enter time on
Here's the problem....I have three components...A Page that contains a User Control and a
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is my code (Say we have a single button on the page that
Here's the flow that I am trying to achieve: 1) User uploads an audio
Here's the scenario: I have a local git repository that mirrors the contents of
Here are the 2 methods and the first error is complaining that I need
Here's the deal: I'm in the process of planning a mid-sized business application that
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.