Question: I am testing terminal based calculator using cucumber BDD testing tool. And using Cygwin for windows. I have written a sample code for addition. The

I am testing terminal based calculator using cucumber BDD testing tool. And using Cygwin for windows. I have written a sample code for addition. The feature file and the step definition is as follows. I want to write similar feature file and step definition for the division. Can you please write down similar test for the division which could take care of all possibilities.

Feature file:

Feature: Addition is handled properly
A calculator should be able to add numbers together and return the correct result.
Scenario: Additive Identity
Given a is zero
Given b is 99
When a is added to b

Then I should get 99

Step definition file

const assert = require('assert');
const { Given, When, Then } = require('cucumber');
// Our calc program that we are testing
const {bc} = require('../../src/bc.js');
Given('a is zero', function () {
this.a = 0;
});
Given('b is {int}', function (int) {
this.b = int;
});
When('a is added to b', function () {
// Create our expression to pass to the 'bc' calculator command.
const expression = `${this.a} + ${this.b}`;
// Run the calculator.
this.result = bc(expression);
});
Then('I should get {int}', function (int) {
assert.strictEqual(this.result, int);
});

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!