Jonathan VUILLEMIN
PHP, Go, mostly.
Behavior-driven development livecoding session in PHP
with Behat, PHPSpec and PHPUnit.
Jonathan VUILLEMIN
October 2019
(quickly, as that's not the goal today)
BDD is a process designed to aid the management and the delivery of software development projects by improving communication between engineers and business professionals.
In so doing, BDD ensures all development projects remain focused on delivering what the business actually needs while meeting all requirements of the user.
Behaviour Driven Development
Quick notes:
Simplified BDD workflow
Check these guys !
Some BDD cool PHP tools quick tour.
The ubiquitous language
Feature: Article publishing while authenticated
Background:
Given I have a user account with username "ekkinox"
And I have the "author" role
And I have the "publisher" role
Scenario: I want to publish an article
Given I am logged as "ekkinox"
When I publish an article named "BDD is magic"
Then I should see an article named "BDD is magic"
And ...
But ...
BDD framework for PHP to help you test business expectations
Scenario: I want to publish an article
Given I am logged as "ekkinox"
/**
* @Given I am logged as :arg1
*/
public function iAmLoggedAs($arg1)
{
$this->loginService->login($arg1);
Assert::assertTrue($this->loginService->isLogged());
Assert::assertEquals($arg1, $this->loginService->getLoggedUserName());
}
Toolset to drive emergent design by specification
class LoginServiceSpec extends ObjectBehavior
{
function it_has_by_default_no_logged_user()
{
$this->getLoggedUserName()->shouldReturn(null);
}
}
Do you want me to create `MyProject\Service\LoginService::getLoggedUserName()`for you?
[Y/n]
Programmer-oriented testing framework for PHP
$stub = $this->createMock(SomeClass::class);
$stub->method('doSomething')->willReturn('foo');
$this->assertEquals('foo', $stub->doSomething());
PHP live coding example:
Create a (very simple) bank account management.
Sources can be found here:
Thank you !
By Jonathan VUILLEMIN
PHP BDD livecoding session slides