Exercise¶

⏲️ 15 minutes

In this step it is your turn to implement the subtraction feature of the calculator.

1- Add the following scenario to the Calculator.feature file.

Scenario: Subtract two numbers
    Given the first number is 120
    And the second number is 70
    When the two numbers are subtracted
    Then the result should be 50

2- Build the solution. The build should succeed.

3- Run the tests. Notice that you have now 2 tests (corresponding to your two scenarios) and the second scenario is “Skipped” because of missing bindings.
Test Explorer Failed Test

4- Click on the “Open additional output for this result” and review the details of the scenario execution.
Test Explorer Additional Output

Now it is your turn to implement the subtraction feature in three short steps:

  1. First add the missing binding (with the minimum code structure necessary) to get a red scenario.
  2. Next turn the scenario green by actually implementing the subtraction logic in the calculator.
  3. Refactor your implementation if necessary (scenarios should remain green).

Did it work out? 🏆

Check the next step for a possible solution.