Discussion:
[Cucumber] Cucumber-cpp Calc example with Boost - BOOST_FAIL does nothing
(too old to reply)
Mollekid
2017-09-28 13:28:48 UTC
Permalink
Raw Message
Hi

I'm trying to test out the cucumber-cpp examples, packed with the
cucumper-cpp project.

I'm able to run the cucumber features and it passes:

# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers

Scenario Outline: Add two numbers #
examples/Calc/features/addition.feature:7
Given I have entered <input_1> into the calculator #
examples/Calc/features/addition.feature:8
And I have entered <input_2> into the calculator #
examples/Calc/features/addition.feature:9
When I press <button> #
examples/Calc/features/addition.feature:10
Then the result should be <output> on the screen #
examples/Calc/features/addition.feature:11

Examples:
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
| 10 | 6 | add | 16 |

# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction

Scenario: Regular numbers #
examples/Calc/features/division.feature:6
Given I have entered 3 into the calculator #
BoostCalculatorSteps.cpp:13
And I have entered 2 into the calculator #
BoostCalculatorSteps.cpp:13
When I press divide #
BoostCalculatorSteps.cpp:26
Then the result should be 1.5 on the screen #
BoostCalculatorSteps.cpp:32

5 scenarios (5 passed)
20 steps (20 passed)
0m1.885s


*But if I want it to fail intentionally and I add a BOOST_FAIL, it seems
to skip the rest and pass like the example above, as I don't expect it to.*

Example:

THEN("^the result should be (.*) on the screen$") {
REGEX_PARAM(double, expected);
ScenarioScope<CalcCtx> context;

* BOOST_FAIL("Please fail me"); // Does not fail the scenario*
* BOOST_CHECK_EQUAL(1, 0); // Does not fail because of BOOST_FAIL*

//BOOST_CHECK_EQUAL(expected, context->result);
}

If I change the order of the BOOST_FAIL and BOOST_CHECK_EQUAL and run the
test again it fails.

# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers

Scenario Outline: Add two numbers #
examples/Calc/features/addition.feature:7
Given I have entered <input_1> into the calculator #
examples/Calc/features/addition.feature:8
And I have entered <input_2> into the calculator #
examples/Calc/features/addition.feature:9
When I press <button> #
examples/Calc/features/addition.feature:10
Then the result should be <output> on the screen #
examples/Calc/features/addition.feature:11

Examples:
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:15:in `Then the result should
be 50 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 2 | 5 | add | 7 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:16:in `Then the result should
be 7 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 0 | 40 | add | 40 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:17:in `Then the result should
be 40 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 10 | 6 | add | 16 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:18:in `Then the result should
be 16 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'

# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction

Scenario: Regular numbers #
examples/Calc/features/division.feature:6
Given I have entered 3 into the calculator #
BoostCalculatorSteps.cpp:13
And I have entered 2 into the calculator #
BoostCalculatorSteps.cpp:13
When I press divide #
BoostCalculatorSteps.cpp:26
Then the result should be 1.5 on the screen #
BoostCalculatorSteps.cpp:32
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/division.feature:10:in `Then the result should
be 1.5 on the screen'

Failing Scenarios:
cucumber examples/Calc/features/addition.feature:15 # Scenario Outline: Add
two numbers, Examples (#1)
cucumber examples/Calc/features/addition.feature:16 # Scenario Outline: Add
two numbers, Examples (#2)
cucumber examples/Calc/features/addition.feature:17 # Scenario Outline: Add
two numbers, Examples (#3)
cucumber examples/Calc/features/addition.feature:18 # Scenario Outline: Add
two numbers, Examples (#4)
cucumber examples/Calc/features/division.feature:6 # Scenario: Regular
numbers

5 scenarios (5 failed)
20 steps (5 failed, 15 passed)
0m1.839s

Setup:
Fedora: 3.12.6-200.fc19.x86_64
Ruby v. 2.4.0
cmake version 3.9.0-rc4
Boost 1.53

/Mollekid
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paolo Ambrosio
2017-09-28 19:58:23 UTC
Permalink
Raw Message
Hi,

I believe the root cause for your problem is the same as this bug:
https://github.com/cucumber/cucumber-cpp/issues/81

Kamil has created a PR to fix it:
https://github.com/cucumber/cucumber-cpp/pull/164

Unfortunately we are experiencing some issues with the CI setup
(https://github.com/cucumber/cucumber-cpp/issues/169) but it will be
merged as soon as we resolve them.

Cheers,
Paolo
Post by Mollekid
Hi
I'm trying to test out the cucumber-cpp examples, packed with the
cucumper-cpp project.
# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario Outline: Add two numbers #
examples/Calc/features/addition.feature:7
Given I have entered <input_1> into the calculator #
examples/Calc/features/addition.feature:8
And I have entered <input_2> into the calculator #
examples/Calc/features/addition.feature:9
When I press <button> #
examples/Calc/features/addition.feature:10
Then the result should be <output> on the screen #
examples/Calc/features/addition.feature:11
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
| 10 | 6 | add | 16 |
# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers #
examples/Calc/features/division.feature:6
Given I have entered 3 into the calculator #
BoostCalculatorSteps.cpp:13
And I have entered 2 into the calculator #
BoostCalculatorSteps.cpp:13
When I press divide #
BoostCalculatorSteps.cpp:26
Then the result should be 1.5 on the screen #
BoostCalculatorSteps.cpp:32
5 scenarios (5 passed)
20 steps (20 passed)
0m1.885s
But if I want it to fail intentionally and I add a BOOST_FAIL, it seems to
skip the rest and pass like the example above, as I don't expect it to.
THEN("^the result should be (.*) on the screen$") {
REGEX_PARAM(double, expected);
ScenarioScope<CalcCtx> context;
BOOST_FAIL("Please fail me"); // Does not fail the scenario
There is a bug open about this:
https://github.com/cucumber/cucumber-cpp/issues/81

Kamil has created a PR to fix it:
https://github.com/cucumber/cucumber-cpp/pull/164

Unfortunately we are experiencing some issues with the CI setup
(https://github.com/cucumber/cucumber-cpp/issues/169) but it will be
merged can't be merged.
Post by Mollekid
BOOST_CHECK_EQUAL(1, 0); // Does not fail because of BOOST_FAIL
//BOOST_CHECK_EQUAL(expected, context->result);
}
If I change the order of the BOOST_FAIL and BOOST_CHECK_EQUAL and run the
test again it fails.
# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario Outline: Add two numbers #
examples/Calc/features/addition.feature:7
Given I have entered <input_1> into the calculator #
examples/Calc/features/addition.feature:8
And I have entered <input_2> into the calculator #
examples/Calc/features/addition.feature:9
When I press <button> #
examples/Calc/features/addition.feature:10
Then the result should be <output> on the screen #
examples/Calc/features/addition.feature:11
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:15:in `Then the result should
be 50 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 2 | 5 | add | 7 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:16:in `Then the result should
be 7 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 0 | 40 | add | 40 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:17:in `Then the result should
be 40 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
| 10 | 6 | add | 16 |
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/addition.feature:18:in `Then the result should
be 16 on the screen'
examples/Calc/features/addition.feature:11:in `Then the result should
be <output> on the screen'
# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers #
examples/Calc/features/division.feature:6
Given I have entered 3 into the calculator #
BoostCalculatorSteps.cpp:13
And I have entered 2 into the calculator #
BoostCalculatorSteps.cpp:13
When I press divide #
BoostCalculatorSteps.cpp:26
Then the result should be 1.5 on the screen #
BoostCalculatorSteps.cpp:32
check 1 == 0 failed [ != ] (Cucumber::WireSupport::WireException)
examples/Calc/features/division.feature:10:in `Then the result should
be 1.5 on the screen'
cucumber examples/Calc/features/addition.feature:15 # Scenario Outline: Add
two numbers, Examples (#1)
cucumber examples/Calc/features/addition.feature:16 # Scenario Outline: Add
two numbers, Examples (#2)
cucumber examples/Calc/features/addition.feature:17 # Scenario Outline: Add
two numbers, Examples (#3)
cucumber examples/Calc/features/addition.feature:18 # Scenario Outline: Add
two numbers, Examples (#4)
cucumber examples/Calc/features/division.feature:6 # Scenario: Regular
numbers
5 scenarios (5 failed)
20 steps (5 failed, 15 passed)
0m1.839s
Fedora: 3.12.6-200.fc19.x86_64
Ruby v. 2.4.0
cmake version 3.9.0-rc4
Boost 1.53
/Mollekid
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mollekid
2017-10-05 07:26:34 UTC
Permalink
Raw Message
Hi Paolo

Thanks for the details, I will just work around it until then.

I have looked for support for debugging the step definitions I write, but
only cam across Pry for ruby. Is there a way to debug?

I also experienced that if i call a function that throws an exception that
I do not catch, the step passes without failing. Is it wrong for me to
expect that it would fail if an exception was not caught?

/Mollekid
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...