Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions