SlideShare a Scribd company logo
Microservice-Teststrategie
mit
Symfony2
ein Vortrag von Per Bernhardt
Mein Name ist Per
http://perprogramming.de
Ich bin ein Chefkoch
http://www.chefkoch.de
Agenda
• Worum geht es?
• Microservices
• Testarten
• Teststrategien
• Zusammenfassung
• Q & A
Worum geht es?
Erstmal vielen Dank
an Toby Clemson!
http://martinfowler.com/articles/microservice-testing/
Microservice Teststrategie mit Symfony2
Microservices!
Microservices!
Teststrategie!
Microservices!
Teststrategie!
?
Microservices!
Teststrategie!
?!
Microservices!
Teststrategie!
?!
Microservices!
Teststrategie!
?!@
Microservices
A microservice architecture is […]
the single responsibility principle
at the architectural level.
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#definition
Microservice Teststrategie mit Symfony2
App
Bundle
Bundle
Bundle
App
Bundle
Bundle
Bundle
App
Bundle
App
Bundle
App
Bundle
Microservice Teststrategie mit Symfony2
@
@
Chefkoch
@
Chefkoch
Recipe User CMS
Video Blog Image
@
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#anatomy-modules
Microservice Teststrategie mit Symfony2
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
Testarten
Unit Tests
Unit Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-unit-diagram
Unit Tests
Unit Tests
Unit Tests
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Unit Tests
Symfony
Service Layer
Entities
Repositories
Doctrine ORM
Gateways
Guzzle
@
Integration Tests
Integration Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-integration-diagram
<?php



$config = DoctrineORMToolsSetup::createAnnotationMetadataConfiguration(

'/path/to/config/files'

);



$entityManager = DoctrineORMEntityManager::create(

[

'driver' => 'pdo_mysql',

'host' => 'localhost',

'user' => 'root',

'password' => '',

'dbname' => 'recipe'

],

$config

);


$repository = $entityManager->getRepository(

'ChefkochRecipeDomainModelRecipe'

);
@
<?php



$config = DoctrineORMToolsSetup::createAnnotationMetadataConfiguration(

'/path/to/config/files'

);



$entityManager = DoctrineORMEntityManager::create(

[

'driver' => 'pdo_mysql',

'host' => 'localhost',

'user' => 'root',

'password' => '',

'dbname' => 'recipe'

],

$config

);


$repository = $entityManager->getRepository(

'ChefkochRecipeDomainModelRecipe'

);
@
Component Tests
Component Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-component-in-process-diagram
Component Tests
Component Tests
Component Tests
WebTestCase!
Component Tests
WebTestCase!
SQLite
Component Tests
WebTestCase!
SQLite Mock Handler
<?php



namespace ChefkochBundleRecipeBundleTestsController;



use SymfonyBundleFrameworkBundleTestWebTestCase;



class RecipeStartpageControllerTest extends WebTestCase

{



public function testRecipeStartpage()

{

$client = self::createClient();

$client->request('GET', '/rezepte');

$this->assertContains('Rezepte', $client->getResponse()->getContent());

}

}
@
# config_test.yml

doctrine:

dbal:

driver: pdo_sqlite

memory: true
<?php



namespace ChefkochBundleRecipeBundleTestController;

use SymfonyBundleFrameworkBundleTestWebTestCase as BaseWebTestCase;

use DoctrineORMEntityManager;

use DoctrineORMToolsSchemaTool;



abstract class WebTestCase extends BaseWebTestCase

{

public function setUp()

{

$entityManager = self::getClient()->getContainer()->get(

'doctrine.orm.default_entity_manager'

);

$schemaTool = new SchemaTool($entityManager);

$schemaTool->createSchema(

$entityManager->getMetadataFactory()->getAllMetadata()

);

}

}
<?php



use GuzzleHttpClient;

use GuzzleHttpHandlerMockHandler;

use GuzzleHttpHandlerStack;

use GuzzleHttpPsr7Response;



$mock = new MockHandler([

new Response(

200,

['Content-Type' => 'application/json'],

'{"id": "1", "title": "Suppe"}'

)

]);



$handler = HandlerStack::create($mock);



$client = new Client(

['handler' => $handler]

);
Component Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-component-out-of-process-diagram
„Out of Process“
@
@
var casper = require('casper').create();



casper.test.begin('Teste Rezeptsuche', 2, function suite(test) {

casper.start("http://api/v2/recipes", function() {

test.assertHttpStatus(200);

test.assertEquals(10, JSON.parse(this.getPageContent()).results.length);

});

casper.run(function() {

test.done();

});

});
Contract Tests
Contract Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-contract-diagram
End-To-End Tests
End-To-End Tests
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#testing-end-to-end-diagram
@
@
@
@
/
@
Feature: Admin Integration

Als Salesmitarbeiter möchte ich das Wettbewerbsbackend

über den normalen Admin verwenden können



@mink:selenium2

Scenario: Login über Admin

Given A sales user "admin" with password "tester"

Given I am on "https://admin-local/rezeptwettbewerbe/admin"

Then I should see "Benutzername:"

When I fill in "Benutzername:" with "admin"

When I fill in "Passwort:" with "tester"

When I press "Einloggen!"

Then I should see "Liste der Rezeptwettbewerbe"

And I should see "Logout"

And I should see "Hallo admin!"
Teststrategien
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#conclusion-test-pyramid
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#conclusion-options
Zusammenfassung
Zusammenfassung
„
“
Quelle: http://martinfowler.com/articles/microservice-testing/#conclusion-summary
Vielen

Dank !
?Fragen
http://chefkoch.jobs - We are hiring ;)
http://perprogramming.de
info@perprogramming.de

More Related Content

PPTX
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
PDF
Application Layer in PHP
PDF
Kubernetes: Wie Chefkoch.de mit Containern arbeitet
PDF
What happens in laravel 4 bootstraping
PPT
Symfony2 and AngularJS
PDF
Cloud Automation with Opscode Chef
PDF
Symfony: Your Next Microframework (SymfonyCon 2015)
PDF
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
Application Layer in PHP
Kubernetes: Wie Chefkoch.de mit Containern arbeitet
What happens in laravel 4 bootstraping
Symfony2 and AngularJS
Cloud Automation with Opscode Chef
Symfony: Your Next Microframework (SymfonyCon 2015)
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017

What's hot (20)

PPT
Dance for the puppet master: G6 Tech Talk
PDF
Symfony tips and tricks
KEY
Puppet for dummies - ZendCon 2011 Edition
PDF
Symfony 2
PDF
はじめてのSymfony2
ODP
Implementing Comet using PHP
PDF
AnyMQ, Hippie, and the real-time web
PDF
AnsibleFest 2014 - Role Tips and Tricks
PDF
Scaling up task processing with Celery
KEY
Quality Use Of Plugin
KEY
PyCon US 2012 - State of WSGI 2
KEY
PDF
Selenium sandwich-3: Being where you aren't.
PDF
Inside Bokete: Web Application with Mojolicious and others
PDF
Nodejs first class
KEY
Phpne august-2012-symfony-components-friends
KEY
Composer
PDF
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
KEY
Plack - LPW 2009
PPTX
Node.js Express
Dance for the puppet master: G6 Tech Talk
Symfony tips and tricks
Puppet for dummies - ZendCon 2011 Edition
Symfony 2
はじめてのSymfony2
Implementing Comet using PHP
AnyMQ, Hippie, and the real-time web
AnsibleFest 2014 - Role Tips and Tricks
Scaling up task processing with Celery
Quality Use Of Plugin
PyCon US 2012 - State of WSGI 2
Selenium sandwich-3: Being where you aren't.
Inside Bokete: Web Application with Mojolicious and others
Nodejs first class
Phpne august-2012-symfony-components-friends
Composer
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Plack - LPW 2009
Node.js Express
Ad

More from Per Bernhardt (12)

PDF
Die Rolle des CTO
PDF
Event Carried State Transfer @ LeanIX
PPTX
Communication in a Microservice Architecture (Ljubljana Backend Meetup 2021)
PDF
Microservice Test Strategy (@Bonn Code Meetup)
PPTX
Communication in a Microservice Architecture
PDF
Magazin-Relaunch bei Chefkoch
PDF
Contract Tests mit Pact
PDF
Chefkoch goes Drupal8
PDF
Umzug eines Hochlast-Dienstes
PDF
kubernetes @ chefkoch.de - Kubernetes Meetup Cologne
PDF
Continiuous Integration and Delivery with Bamboo
PDF
Anwendungsintegration mit Edge Side Includes
Die Rolle des CTO
Event Carried State Transfer @ LeanIX
Communication in a Microservice Architecture (Ljubljana Backend Meetup 2021)
Microservice Test Strategy (@Bonn Code Meetup)
Communication in a Microservice Architecture
Magazin-Relaunch bei Chefkoch
Contract Tests mit Pact
Chefkoch goes Drupal8
Umzug eines Hochlast-Dienstes
kubernetes @ chefkoch.de - Kubernetes Meetup Cologne
Continiuous Integration and Delivery with Bamboo
Anwendungsintegration mit Edge Side Includes
Ad

Recently uploaded (20)

PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PDF
Understanding NFT Marketplace Development_ Trends and Innovations.pdf
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PPTX
Save Business Costs with CRM Software for Insurance Agents
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
PDF
Become an Agentblazer Champion Challenge Kickoff
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Benefits of DCCM for Genesys Contact Center
PPTX
Mastering-Cybersecurity-The-Crucial-Role-of-Antivirus-Support-Services.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Convert Thunderbird to Outlook into bulk
PPTX
How a Careem Clone App Allows You to Compete with Large Mobility Brands
PPT
JAVA ppt tutorial basics to learn java programming
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PDF
How to Choose the Most Effective Social Media Agency in Bangalore.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
Understanding NFT Marketplace Development_ Trends and Innovations.pdf
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Save Business Costs with CRM Software for Insurance Agents
Upgrade and Innovation Strategies for SAP ERP Customers
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
Become an Agentblazer Champion Challenge Kickoff
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Benefits of DCCM for Genesys Contact Center
Mastering-Cybersecurity-The-Crucial-Role-of-Antivirus-Support-Services.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Convert Thunderbird to Outlook into bulk
How a Careem Clone App Allows You to Compete with Large Mobility Brands
JAVA ppt tutorial basics to learn java programming
How Creative Agencies Leverage Project Management Software.pdf
The Role of Automation and AI in EHS Management for Data Centers.pdf
How to Choose the Most Effective Social Media Agency in Bangalore.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf

Microservice Teststrategie mit Symfony2