The following commands help you build, launch the steps applications, and run the Cucumber test cases, respectively. To be precise, the first command builds the test cases, while the second command launches the Cucumber steps test executable in the background mode. The third command executes the Cucumber test case that we wrote for the RPNCalculator project. The RPNCalculatorSteps executable will work as a server that Cucumber can talk to via the wire protocol. The Cucumber framework will get the connection details of the server from the cucumber.wire file kept under the step_definitions folder:
cmake --build build
build/RPNCalculator/RPNCalculatorSteps &
cucumber RPNCalculator
The following screenshot demonstrates the Cucumber test case execution procedure:

I'm sure you've got the hang of BDD! Yes, BDD is pretty simple and straightforward. Now let's add a scenario for the division operation as shown in the following screenshot:

Let's quickly run the test case and observe the test outcome, as shown in the following screenshot:

Yes, I heard you saying you know the reason for the failure. Let's quickly add support for division and rerun the test cases to see it turn all green! BDD makes coding really fun.
We need to add the following code snippet in RPNCalculator.cpp:
else if ( *token == "/" ) {
secondNumber = numberStack.top();
numberStack.pop();
firstNumber = numberStack.top();
numberStack.pop();
result = firstNumber / secondNumber;
numberStack.push ( result );
}
With this code change, let's check the test output:
cmake --build build
build/RPNCalculator/RPNCalculatorSteps &
cucumber RPNCalculator
The following screenshot demonstrates the procedure visually:

So far so good. All the scenarios we tested so far have passed, which is a good sign. But let's try a complex expression that involves many math operations. For instance, let's try 10.0 5.0 * 1.0 + 100.0 2.0 / -.
Reverse Polish Notation (postfix notation) is used by pretty much every compiler to evaluate mathematical expressions.
The following screenshot demonstrates the integration of the complex expression test case:

Let's run the test scenarios one more time, as this would be a real test for the entire code implemented so far, as this expression involves all the operations our simple application supports.
The following command can be used to launch the application in the background mode and to execute the Cucumber test cases:
build/RPNCalculator/RPNCalculatorSteps &
cucumber RPNCalculator
The following screenshot demonstrates the procedure visually:

Great! If you have come this far, I'm sure you would have understood cucumber-cpp and the BDD style of coding.
The RPNCalculator.cpp code has too much branching, which is a code smell; hence, the code could be refactored. The good news is that RPNCalculator.cpp can be refactored to remove the code smells and has the scope to use the Factory Method, Strategy, and Null Object Design Patterns.