Given
(/^I have entered (d+) into the
calculator$/)
do |n|
calculator - Calculator.new
calculator.push(n.to_i)
end
class Calculator
def push(n)
@args ||= []
@args << n
end
end
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers
Given I have entered 23 into the
calculator
And I have entered 41 into the
calculator
When I press add
Then the result should be 64 on the
screen
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers
Given I have entered 23 into the
calculator
And I have entered 41 into the
calculator
When I press add
Then the result should be 64 on the
screen
using cucumber::ScenarioScope;
struct CalcCtx {
Calculator calc;
double result;
};
GIVEN("^I have entered (d+) into the calculator$")
{
REGEX_PARAM(double, n);
ScenarioScope<CalcCtx> context;
context->calc.push(n);
}
class Calculator {
public:
void push(int n) {
stack.push_back(n);
}
private:
std::vector<int>
stack;
};
https://github.com/
https://travis-ci.org/
https://coveralls.io/
https://godoc.org/
https://cukes.info/
https://golang.org/
https://github.com/
https://coveralls.io/
https://travis-ci.org/
Test Driven Development: By Example
Kent Beck
Growing object-oriented software guided by tests
Steve Freeman, Nat Pryce
Modern C++ Programming with Test-Driven Development:
Code Better, Sleep Better
Jeff Langr
The Pragmatic Programmer: From Journeyman to Master
Andrew Hunt, David Thomas
Becoming a Better Programmer: A Handbook for People
Who Care About Code
Pete Goodliffe

A story about my journey in the land of programming practices

  • 8.
    Given (/^I have entered(d+) into the calculator$/) do |n| calculator - Calculator.new calculator.push(n.to_i) end class Calculator def push(n) @args ||= [] @args << n end end Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 23 into the calculator And I have entered 41 into the calculator When I press add Then the result should be 64 on the screen
  • 9.
    Feature: Addition In orderto avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 23 into the calculator And I have entered 41 into the calculator When I press add Then the result should be 64 on the screen using cucumber::ScenarioScope; struct CalcCtx { Calculator calc; double result; }; GIVEN("^I have entered (d+) into the calculator$") { REGEX_PARAM(double, n); ScenarioScope<CalcCtx> context; context->calc.push(n); } class Calculator { public: void push(int n) { stack.push_back(n); } private: std::vector<int> stack; };
  • 16.
  • 17.
  • 18.
  • 19.
  • 31.
  • 32.
    Test Driven Development:By Example Kent Beck Growing object-oriented software guided by tests Steve Freeman, Nat Pryce Modern C++ Programming with Test-Driven Development: Code Better, Sleep Better Jeff Langr The Pragmatic Programmer: From Journeyman to Master Andrew Hunt, David Thomas Becoming a Better Programmer: A Handbook for People Who Care About Code Pete Goodliffe