El documento habla sobre el desarrollo guiado por comportamiento (BDD) usando las herramientas Symfony2, Behat y Mink. Explica qué es BDD, cómo se definen historias de usuario y escenarios usando Gherkin, y cómo Behat permite automatizar las pruebas. También cubre cómo integrar Behat con Symfony2 usando el bundle Behat y ejecutar las pruebas, y el uso de Mink para realizar pruebas funcionales web que simulan la interacción del usuario.
My talk at the Symfony Online 2023 Conference.
Many developers fail to use a debugger like Xdebug in their day to day activities. In this talk we explain:
- Why you really want to be using a debugger
- How do you install and configure it easily
- How it interacts with your Symfony application
- How you can use it for more than just debugging your application, how you can actually use it to drive your development.
2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
My talk at the Symfony Online 2023 Conference.
Many developers fail to use a debugger like Xdebug in their day to day activities. In this talk we explain:
- Why you really want to be using a debugger
- How do you install and configure it easily
- How it interacts with your Symfony application
- How you can use it for more than just debugging your application, how you can actually use it to drive your development.
2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
Antes de iniciar el contenido técnico de lo acontecido en materia tributaria estos últimos días de mayo; quisiera referirme a la importancia de una expresión tan sabia aplicable a tantas situaciones de la vida, y hoy, meritoria de considerar en el prefacio del presente análisis -
"no se extraña lo que nunca se ha tenido".
Con esta frase me quiero referir a las empresas que funcionan en las zonas de Iquique y Punta Arenas, acogidas a los beneficios de las zonas francas, y que, por ende, no pagan impuesto de primera categoría. En palabras técnicas estas empresas no mantienen saldos en sus registros SAC, y por ello, este nuevo Impuesto Sustitutivo, sin duda, es una tremenda y gran noticia.
Lo mismo se puede extender a las empresas que por haber aplicado beneficios de reinversión sumado a las ventajas transitorias de la menor tasa de primera categoría pagada; me refiero a las pymes en su mayoría. Han acumulado un monto de créditos menor en su registro SAC.
En estos casos, no es mucho lo que se tiene que perder.
Lo interesante, es que este ISRAI nace desde un pago efectivo de recursos, lo que exigirá a las empresas evaluar muy bien desde su posición financiera actual, y la planificación de esta, en un horizonte de corto plazo, considerar las alternativas que se disponen.
El 15 de mayo de 2024, el Congreso aprobó el proyecto de ley que “crea un Fondo de Emergencia Transitorio por incendios y establece otras medidas para la reconstrucción”, el cual se encuentra en las últimas etapas previo a su publicación y posterior entrada en vigencia.
Este proyecto tiene por objetivo establecer un marco institucional para organizar los esfuerzos públicos, con miras a solventar los gastos de reconstrucción y otras medidas de recuperación que se implementarán en la Región de Valparaíso a raíz de los incendios ocurridos en febrero de 2024.
Dentro del marco de “otras medidas de reconstrucción”, el proyecto crea un régimen opcional de impuesto sustitutivo de los impuestos finales (denominado también ISRAI), con distintas modalidades para sociedades bajo el régimen general de tributación (artículo 14 A de la ley sobre Impuesto a la Renta) y bajo el Régimen Pyme (artículo 14 D N° 3 de la ley sobre Impuesto a la Renta).
Para conocer detalles revisa nuestro artículo completo aquí BBSC® Impuesto Sustitutivo 2024.
Por Claudia Valdés Muñoz cvaldes@bbsc.cl +56981393599
“La teoría de la producción sostiene que en un proceso productivo que se caracteriza por tener factores fijos (corto plazo), al aumentar el uso del factor variable, a partir de cierta tasa de producción
EL MERCADO LABORAL EN EL SEMESTRE EUROPEO. COMPARATIVA.ManfredNolte
Hoy repasaremos a uña de caballo otro reciente documento de la Comisión (SWD-2024) que lleva por título ‘Análisis de países sobre la convergencia social en línea con las características del Marco de Convergencia Social (SCF)’.
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
This article is all about what AI trends will emerge in the field of creative operations in 2024. All the marketers and brand builders should be aware of these trends for their further use and save themselves some time!
Antes de iniciar el contenido técnico de lo acontecido en materia tributaria estos últimos días de mayo; quisiera referirme a la importancia de una expresión tan sabia aplicable a tantas situaciones de la vida, y hoy, meritoria de considerar en el prefacio del presente análisis -
"no se extraña lo que nunca se ha tenido".
Con esta frase me quiero referir a las empresas que funcionan en las zonas de Iquique y Punta Arenas, acogidas a los beneficios de las zonas francas, y que, por ende, no pagan impuesto de primera categoría. En palabras técnicas estas empresas no mantienen saldos en sus registros SAC, y por ello, este nuevo Impuesto Sustitutivo, sin duda, es una tremenda y gran noticia.
Lo mismo se puede extender a las empresas que por haber aplicado beneficios de reinversión sumado a las ventajas transitorias de la menor tasa de primera categoría pagada; me refiero a las pymes en su mayoría. Han acumulado un monto de créditos menor en su registro SAC.
En estos casos, no es mucho lo que se tiene que perder.
Lo interesante, es que este ISRAI nace desde un pago efectivo de recursos, lo que exigirá a las empresas evaluar muy bien desde su posición financiera actual, y la planificación de esta, en un horizonte de corto plazo, considerar las alternativas que se disponen.
El 15 de mayo de 2024, el Congreso aprobó el proyecto de ley que “crea un Fondo de Emergencia Transitorio por incendios y establece otras medidas para la reconstrucción”, el cual se encuentra en las últimas etapas previo a su publicación y posterior entrada en vigencia.
Este proyecto tiene por objetivo establecer un marco institucional para organizar los esfuerzos públicos, con miras a solventar los gastos de reconstrucción y otras medidas de recuperación que se implementarán en la Región de Valparaíso a raíz de los incendios ocurridos en febrero de 2024.
Dentro del marco de “otras medidas de reconstrucción”, el proyecto crea un régimen opcional de impuesto sustitutivo de los impuestos finales (denominado también ISRAI), con distintas modalidades para sociedades bajo el régimen general de tributación (artículo 14 A de la ley sobre Impuesto a la Renta) y bajo el Régimen Pyme (artículo 14 D N° 3 de la ley sobre Impuesto a la Renta).
Para conocer detalles revisa nuestro artículo completo aquí BBSC® Impuesto Sustitutivo 2024.
Por Claudia Valdés Muñoz cvaldes@bbsc.cl +56981393599
“La teoría de la producción sostiene que en un proceso productivo que se caracteriza por tener factores fijos (corto plazo), al aumentar el uso del factor variable, a partir de cierta tasa de producción
EL MERCADO LABORAL EN EL SEMESTRE EUROPEO. COMPARATIVA.ManfredNolte
Hoy repasaremos a uña de caballo otro reciente documento de la Comisión (SWD-2024) que lleva por título ‘Análisis de países sobre la convergencia social en línea con las características del Marco de Convergencia Social (SCF)’.
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
This article is all about what AI trends will emerge in the field of creative operations in 2024. All the marketers and brand builders should be aware of these trends for their further use and save themselves some time!
A report by thenetworkone and Kurio.
The contributing experts and agencies are (in an alphabetical order): Sylwia Rytel, Social Media Supervisor, 180heartbeats + JUNG v MATT (PL), Sharlene Jenner, Vice President - Director of Engagement Strategy, Abelson Taylor (USA), Alex Casanovas, Digital Director, Atrevia (ES), Dora Beilin, Senior Social Strategist, Barrett Hoffher (USA), Min Seo, Campaign Director, Brand New Agency (KR), Deshé M. Gully, Associate Strategist, Day One Agency (USA), Francesca Trevisan, Strategist, Different (IT), Trevor Crossman, CX and Digital Transformation Director; Olivia Hussey, Strategic Planner; Simi Srinarula, Social Media Manager, The Hallway (AUS), James Hebbert, Managing Director, Hylink (CN / UK), Mundy Álvarez, Planning Director; Pedro Rojas, Social Media Manager; Pancho González, CCO, Inbrax (CH), Oana Oprea, Head of Digital Planning, Jam Session Agency (RO), Amy Bottrill, Social Account Director, Launch (UK), Gaby Arriaga, Founder, Leonardo1452 (MX), Shantesh S Row, Creative Director, Liwa (UAE), Rajesh Mehta, Chief Strategy Officer; Dhruv Gaur, Digital Planning Lead; Leonie Mergulhao, Account Supervisor - Social Media & PR, Medulla (IN), Aurelija Plioplytė, Head of Digital & Social, Not Perfect (LI), Daiana Khaidargaliyeva, Account Manager, Osaka Labs (UK / USA), Stefanie Söhnchen, Vice President Digital, PIABO Communications (DE), Elisabeth Winiartati, Managing Consultant, Head of Global Integrated Communications; Lydia Aprina, Account Manager, Integrated Marketing and Communications; Nita Prabowo, Account Manager, Integrated Marketing and Communications; Okhi, Web Developer, PNTR Group (ID), Kei Obusan, Insights Director; Daffi Ranandi, Insights Manager, Radarr (SG), Gautam Reghunath, Co-founder & CEO, Talented (IN), Donagh Humphreys, Head of Social and Digital Innovation, THINKHOUSE (IRE), Sarah Yim, Strategy Director, Zulu Alpha Kilo (CA).
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
The search marketing landscape is evolving rapidly with new technologies, and professionals, like you, rely on innovative paid search strategies to meet changing demands.
It’s important that you’re ready to implement new strategies in 2024.
Check this out and learn the top trends in paid search advertising that are expected to gain traction, so you can drive higher ROI more efficiently in 2024.
You’ll learn:
- The latest trends in AI and automation, and what this means for an evolving paid search ecosystem.
- New developments in privacy and data regulation.
- Emerging ad formats that are expected to make an impact next year.
Watch Sreekant Lanka from iQuanti and Irina Klein from OneMain Financial as they dive into the future of paid search and explore the trends, strategies, and technologies that will shape the search marketing landscape.
If you’re looking to assess your paid search strategy and design an industry-aligned plan for 2024, then this webinar is for you.
5 Public speaking tips from TED - Visualized summarySpeakerHub
From their humble beginnings in 1984, TED has grown into the world’s most powerful amplifier for speakers and thought-leaders to share their ideas. They have over 2,400 filmed talks (not including the 30,000+ TEDx videos) freely available online, and have hosted over 17,500 events around the world.
With over one billion views in a year, it’s no wonder that so many speakers are looking to TED for ideas on how to share their message more effectively.
The article “5 Public-Speaking Tips TED Gives Its Speakers”, by Carmine Gallo for Forbes, gives speakers five practical ways to connect with their audience, and effectively share their ideas on stage.
Whether you are gearing up to get on a TED stage yourself, or just want to master the skills that so many of their speakers possess, these tips and quotes from Chris Anderson, the TED Talks Curator, will encourage you to make the most impactful impression on your audience.
See the full article and more summaries like this on SpeakerHub here: https://speakerhub.com/blog/5-presentation-tips-ted-gives-its-speakers
See the original article on Forbes here:
http://www.forbes.com/forbes/welcome/?toURL=http://www.forbes.com/sites/carminegallo/2016/05/06/5-public-speaking-tips-ted-gives-its-speakers/&refURL=&referrer=#5c07a8221d9b
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
Everyone is in agreement that ChatGPT (and other generative AI tools) will shape the future of work. Yet there is little consensus on exactly how, when, and to what extent this technology will change our world.
Businesses that extract maximum value from ChatGPT will use it as a collaborative tool for everything from brainstorming to technical maintenance.
For individuals, now is the time to pinpoint the skills the future professional will need to thrive in the AI age.
Check out this presentation to understand what ChatGPT is, how it will shape the future of work, and how you can prepare to take advantage.
A brief introduction to DataScience with explaining of the concepts, algorithms, machine learning, supervised and unsupervised learning, clustering, statistics, data preprocessing, real-world applications etc.
It's part of a Data Science Corner Campaign where I will be discussing the fundamentals of DataScience, AIML, Statistics etc.
Time Management & Productivity - Best PracticesVit Horky
Here's my presentation on by proven best practices how to manage your work time effectively and how to improve your productivity. It includes practical tips and how to use tools such as Slack, Google Apps, Hubspot, Google Calendar, Gmail and others.
The six step guide to practical project managementMindGenius
The six step guide to practical project management
If you think managing projects is too difficult, think again.
We’ve stripped back project management processes to the
basics – to make it quicker and easier, without sacrificing
the vital ingredients for success.
“If you’re looking for some real-world guidance, then The Six Step Guide to Practical Project Management will help.”
Dr Andrew Makar, Tactical Project Management
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
During this webinar, Anand Bagmar demonstrates how AI tools such as ChatGPT can be applied to various stages of the software development life cycle (SDLC) using an eCommerce application case study. Find the on-demand recording and more info at https://applitools.info/b59
Key takeaways:
• Learn how to use ChatGPT to add AI power to your testing and test automation
• Understand the limitations of the technology and where human expertise is crucial
• Gain insight into different AI-based tools
• Adopt AI-based tools to stay relevant and optimize work for developers and testers
* ChatGPT and OpenAI belong to OpenAI, L.L.C.
More than Just Lines on a Map: Best Practices for U.S Bike Routes
This session highlights best practices and lessons learned for U.S. Bike Route System designation, as well as how and why these routes should be integrated into bicycle planning at the local and regional level.
Presenters:
Presenter: Kevin Luecke Toole Design Group
Co-Presenter: Virginia Sullivan Adventure Cycling Association
More than Just Lines on a Map: Best Practices for U.S Bike Routes
BDD con Behat y Mink en Symfony2
1.
2.
3. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Carlos Granados
4. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
5. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
6. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
7. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
¿Qué es BDD?
• Desarrollo basado en comportamiento
funcionalidad
• Pasar tests != funcionalidad conseguida
• Historias en lenguaje natural y compartido
• Lenguaje definido y automatizable
• Las historias dirigen nuestro desarrollo
• Podemos comprobar la funcionalidad
8. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Historias (Stories)
• Características (Features)
• As a [role] I want [feature] so that [benefit]
• Escenarios (Scenarios) y pasos (Steps)
• Precondiciones (Given …)
• Acciones (When…)
• Resultados (Then…)
9. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Feature: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds
Given the account balance is 100€
And the card is valid
And the machine contains enough money
When the Account Holder inserts the card
And the Account Holder requests 20€
Then the ATM should dispense 20€
And the account balance should be 80€
And the card should be returned
Scenario 2: ...
10. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Gherkin
• El lenguaje de cucumber
• Lenguaje natural y comprensible
• Lenguaje específico y definido
• Lenguaje automatizable
• Similar a YAML
• Ficheros .feature
11. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Behat
• BDD para php
• Inspirado por cucumber
• Herramienta de línea de comandos
• Disponible en varios idiomas
• Más información en http://behat.org
12. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
#features/atm.feature
Feature: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario: Account has sufficient funds
Given the account balance is 100€
And the card is valid
And the machine contains enough money
When the Account Holder inserts the card
And the Account Holder requests 20€
Then the ATM should dispense 20€
And the account balance should be 80€
And the card should be returned
Scenario: ...
13. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
$ behat
Feature: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds #features/atm.feature:7
Given the account balance is 100€
...
1 scenario ( 1 undefined)
8 steps (8 undefined)
You can implement undefined steps with these code snippets:
/**
* @Given /^the account balance is (d+)€$/
*/
public function theAccountBalanceIs($argument1)
{
throw new PendingException();
}
...
14. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
// features/bootstrap/FeatureContext.php
<?php
use BehatBehatContextBehatContext,
BehatBehatExceptionPendingException;
class FeatureContext extends BehatContext
{
/**
* @Given /^the account balance is (d+)€$/
*/
public function theAccountBalanceIs ($argument1)
{
throw new PendingException ();
}
}
15. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
// features/bootstrap/FeatureContext.php
<?php
use BehatBehatContextBehatContext,
BehatBehatExceptionPendingException;
class FeatureContext extends BehatContext
{
/**
* @Given /^(?:|the )account balance is (d+)€$/
*/
public function setAccountBalance ($balance)
{
$user = $this->getContainer()->getUser();
$account = $user->getAccount();
$account->setBalance($balance);
}
}
16. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
$ behat
Feature: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds #features/atm.feature:7
Given the account balance is 100€ #featureContext::setAccountBalance()
...
1 scenario (1 pased)
8 steps (8 passed)
17. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
/**
* @Then /^(?:|The )account balance should be (d+)€$/
*/
public function checkAccountBalance ($balance)
{
$user = $this->getContainer()->getUser();
$account = $user->getAccount();
if ($account->getBalance()!=$balance) {
throw new Exception(
'Actual balance is '.$account->getBalance().
'€ instead of '.$balance.'€';
);
}
}
18. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
$ behat
Feature: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds #features/atm.feature:7
...
And the account balance should be 80€ #featureContext::checkAccountBalance()
Actual balance is 100€ instead of 80€
And the card should be returned #featureContext::isCardReturned()
...
1 scenario (1 pased)
8 steps (6 passed, 1 skipped, 1 failed)
19. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';
...
/**
* @Then /^(?:|the )account balance should be (d+)€$/
*/
public function checkAccountBalance ($balance)
{
$user = $this->getContainer()->getUser();
$account = $user->getAccount();
assertEquals($account->getBalance(), $balance);
}
20. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
...
Scenario: Account has insufficient funds
Given the account balance is 10€
And the card is valid
And the machine contains enough money
When the Account Holder inserts the card
And the Account Holder requests 20€
Then the ATM should not dispense any money
And the ATM should print "Insuficient funds"
And the account balance should be 10€
And the card should be returned
Scenario: ...
21. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Then the account balance should be 20€
/**
* @Then /^the account balance should be (d+)€$/
*/
Then the ATM should print "Insuficient funds"
/**
* @Then /^the ATM should print "([^"]*)"$/
*/
22. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Scenario: ...
Given the following users exist:
| name | email | phone |
| Aslak | aslak@email.com | 123 |
| Joe | joe@email.com | 234 |
| Bryan | bryan@email.org | 456 |
/**
* @Given /the following users exist:/
*/
public function insertUsers(TableNode $table)
{
$hash = $table->getHash();
foreach ($hash as $row) {
$user = new User($row['name'], $row['email'], $row['phone']);
$this->database->insert($user);
}
}
23. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Scenario: Eat 5 out of 12
Given there are 12 cucumbers
When I eat 5 cucumbers
Then I should have 7 cucumbers
Scenario: Eat 5 out of 20
Given there are 20 cucumbers
When I eat 5 cucumbers
Then I should have 15 cucumbers
Scenario: Eat 5 out of 5
Given there are 5 cucumbers
When I eat 5 cucumbers
Then I should have 0 cucumbers
24. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Scenario Outline: Eat cucumbers
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
| 5 | 5 | 0 |
25. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Background:
Given the following users exist:
| name | email | phone |
| Aslak | aslak@email.com | 123 |
| Joe | joe@email.com | 234 |
| Bryan | bryan@email.org | 456 |
Scenario:...
Scenario:...
Hooks: http://docs.behat.org/guides/3.hooks.html
26. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
/**
* @Then /^there should be no money in the account$/
*/
public function checkEmptyAccount ()
{
return new Then('the account balance should be 0€');
}
/**
* @When /^the user eats and sleeps$/
*/
public function userEatsAndSleeps ()
{
return array(
new When("the user eats"),
new When("the user sleeps"),
);
}
27. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Behat en Symfony2: BehatBundle
//deps
[gherkin]
git=https://github.com/Behat/Gherkin.git
target=/behat/gherkin
[behat]
git=https://github.com/Behat/Behat.git
target=/behat/behat
[BehatBundle]
git=https://github.com/Behat/BehatBundle.git
target=/bundles/Behat/BehatBundle
28. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
//app/autoload.php
$loader->registerNamespaces(array(
// ..
'BehatGherkin' => __DIR__.'/../vendor/behat/gherkin/src',
'BehatBehat' => __DIR__.'/../vendor/behat/behat/src',
'BehatBehatBundle' => __DIR__.'/../vendor/bundles',
));
//app/AppKernel.php
public function registerBundles()
{
// ..
if ('test' === $this->getEnvironment()) {
$bundles[] = new BehatBehatBundleBehatBundle();
}
}
29. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
$ app/console -e=test behat --init @AcmeDemoBundle
+Acme
+DemoBundle
+...
+Features
+Context
-FeatureContext.php
+...
30. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
//Acme/DemoBundle/Features/Context/FeatureContext.php
<?php
namespace AcmeDemoBundleFeaturesContext;
use BehatBehatBundleContextBehatContext;
class FeatureContext extends BehatContext
{
/**
* @Given /I have a product "([^"]*)"/
*/
public function insertProduct($name)
{
$em = $this->getContainer()->get('doctrine')
->getEntityManager();
$product = new AcmeDemoBundleEntityProduct();
$product->setName($name);
$em->persist($product);
$em->flush();
}
}
31. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
BDD en Symfony2: ejecutar tests
$ app/console –e=test behat @AcmeDemoBundle
32. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Pruebas de funcionalidad web: Mink
• Librería php integrada con behat
• Permite usar distintos Browser emulators
• Controlar el Navegador
• Recorrer la Página
• Manipular la Página
• Simular la interacción del Usuario
• Interface común para todos los emuladores
33. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Tipos de Browser emulators:
• Emuladores Headless Browsers
• Symfony Web Client
• Goutte
• Emuladores Browser controllers
• Selenium
• Sahi
• Mixtos: Zombie.js
34. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Controlar el Navegador
// iniciar driver:
$driver = new BehatMinkDriverGoutteDriver();
// iniciar sesión:
$session = new BehatMinkSession($driver);
// arrancar sesión:
$session->start();
// abrir una página en el navegador:
$session->visit('http://my_project.com/some_page.php');
// obtener el código de respuesta:
echo $session->getStatusCode();
// obtener el contenido de la página:
echo $session->getPage()->getContent();
35. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
// utilizar la historia del navegador:
$session->reload();
$session->back();
$session->forward();
// evaluar expresión Javascript:
echo $session->evaluateScript(
"(function(){ return 'something from browser'; })()"
);
// obtener los headers:
print_r($session->getResponseHeaders());
// guardar cookie:
$session->setCookie('cookie name', 'value');
// obtener cookie:
echo $session->getCookie('cookie name');
36. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Recorrer la Página: selectors
//xpath selector
$handler = new BehatMinkSelectorSelectorsHandler();
$xpath = $handler->selectorToXpath('xpath', '//html');
//css selector
$selector = new BehatMinkSelectorCssSelector();
$xpath = $selector->translateToXPath('#ID');
//named selectors
$selector = new BehatMinkSelectorNamedSelector();
$xpath = $selector->translateToXPath(
array('field', 'id|name|value|label')
);
//named selectors: link, button, content, select, checkbox
//radio, file, optgroup, option, table
37. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Recorrer la Página: obtener elementos
//obtengo la página
$page = $session->getPage();
//encuentro un elemento
$element = $page->find('xpath', '//body');
//encuentro todos los elementos
$elementsByCss = $page->findAll('css', '.classname');
//encuentro un elemento por su Id
$element = $page->findById('ID');
//encuentro elementos con named selectors
$link = $page->findLink('href');
$button = $page->findButton('name');
$field = $page->findField('id');
38. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Manipular la Página: Node Elements
//obtengo un elemento
$el = $page->find('css', '.something');
// obtengo el nombre del tag:
echo $el->getTagName();
// compruebo si tiene un atributo:
$el->hasAttribute('href');
// obtengo un atributo:
echo $el->getAttribute('href');
//obtengo el texto
$plainText = $el->getText();
//obtengo el html
$html = $el->getHtml();
39. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Manipular la Página: Form fields
// marcar/desmarcar checkbox:
if ($el->isChecked()) {
$el->uncheck();
}
$el->check();
// elegir option en select:
$el->selectOption('optin value');
// añadir un fichero:
$el->attachFile('/path/to/file');
// obtener el valor:
echo $el->getValue();
// poner un valor:
$el->setValue('some val');
40. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Simular la interacción del Usuario
// pulsar un botón:
$el->press();
//simular el ratón
$el->click();
$el->doubleClick();
$el->rightClick();
$el->mouseOver();
$el->focus();
$el->blur();
//Hacer drag'n'drop
$el1->dragTo($el2);
41. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Integración con Behat: MinkContext
// features/bootstrap/FeatureContext.php
use BehatMinkBehatContextMinkContext;
class FeatureContext extends MinkContext
{
/**
* @Then /^I press the submit button$/
*/
public function PressSubmitButton()
{
$page = $this->getSession()->getPage();
$button = $page->findButton('submit');
$button->press();
}
}
42. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Steps predefinidos: Given/When
Given I am on "URL"
When I go to "url"
When I reload the page
When I move backward one page
When I move forward one page
When I press "button"
When I follow "link"
When I fill in "field" with "value"
When I fill in "value" for "field"
When I fill in the following:
When I select "option" from "select"
When I additionally select "option" from "select"
When I check "option"
When I uncheck "option"
When I attach the file "path" to "field"
43. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Steps predefinidos: Then
Then I should be on "page"
Then the url should match "pattern"
Then the response status code should be "code"
Then the response status code should not be "code"
Then I should see "text"
Then I should not see "text"
Then I should see "text" in the "element" element
Then the "element" element should contain "value"
Then I should see an "element" element
Then I should not see an "element" element
Then the "field" field should contain "value"
Then the "field" field should not contain "value"
Then the "checkbox" checkbox should be checked
Then the "checkbox" checkbox should not be checked
Then I should see "num" "element" elements
Then print last response
44. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
# features/search.feature
Feature: Search
In order to see a word definition
As a website user
I need to be able to search for a word
Scenario: Searching for a page that does exist
Given I am on "/wiki/Main_Page"
When I fill in "search" with "Behavior Driven Development"
And I press "searchButton"
Then I should see "agile software development"
Scenario: Searching for a page that does NOT exist
Given I am on "/wiki/Main_Page"
When I fill in "search" with "Glory Driven Development"
And I press "searchButton"
Then I should see “No results found"
45. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
/**
* @Given /^I am on the main page$/
*/
public function goToMainPage()
{
return new Given('I am on "/wiki/Main_Page"');
}
/**
* @Then /^I press the search button$/
*/
public function pressSearchButton()
{
return new Then('I press "searchButton"');
}
46. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Mink en Symfony2: MinkBundle
//deps
[mink]
git=https://github.com/Behat/Mink.git
target=/behat/mink
[MinkBundle]
git=https://github.com/Behat/MinkBundle.git
target=/bundles/Behat/MinkBundle
47. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
//app/autoload.php
$loader->registerNamespaces(array(
// ..
'BehatMink' => __DIR__.'/../vendor/behat/mink/src',
'BehatMinkBundle' => __DIR__.'/../vendor/bundles',
));
//app/AppKernel.php
public function registerBundles()
{
// ..
if ('test' === $this->getEnvironment()) {
$bundles[] = new BehatBehatBundleBehatBundle();
$bundles[] = new BehatMinkBundleMinkBundle();
}
}
48. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
#app/config/config_test.yml
mink:
base_url: http://localhost/app_test.php
browser_name: chrome
goutte: ~
sahi: ~
zombie: ~
49. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
//web/app_test.php
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check
'.basename(__FILE__).' for more information.');
}
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
use SymfonyComponentHttpFoundationRequest;
$kernel = new AppKernel('test', true);
$kernel->loadClassCache();
$kernel->handle(Request::createFromGlobals())->send();
50. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
namespace AcmeDemoBundleFeaturesContext;
use BehatMinkBundleContextMinkContext;
class FeatureContext extends MinkContext
{
/**
* @When /^I go to the user account page$/
*/
public function showUserAccount()
{
$user = $this->getContainer()->get('security.context')
->getToken()->getUser();
$session = $this->getSession();
$session->visit('/account/'. $user->getSlug());
}
}
51. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Qué Driver usar
# symfony driver (default)
@mink:symfony
Scenario: ...
# goutte driver
@mink:goutte
Scenario: ...
# sahi driver
@mink:sahi o @javascript
Scenario: ...
# zombie.js driver
@mink:zombie
Scenario: ...
52. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Trucos: Salida de Behat
app/console -e=test behat -f pretty,junit --out ,. @AcmeDemoBundle
53. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Trucos: repetir Tests
app/console -e=test behat --rerun="re.run" @AcmeDemoBundle
54. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
BDD vs TDD
• BDD es TDD
BDD vs UnitTesting
• Unit testing comprueba unidades
• BDD comprueba funcionalidad
55. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
Stop Press!!! Behat 2.4
• BehatBundle y MinkBundle deprecated
• Usar MinkExtension y Symfony2Extension
• Más info en http://behat.org
56. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
//deps
[mink]
git=https://github.com/Behat/Mink.git
target=/behat/mink
version=v1.3.3
[gherkin]
git=https://github.com/Behat/Gherkin.git
target=/behat/gherkin
version=v2.1.1
[behat]
git=https://github.com/Behat/Behat.git
target=/behat/behat
version=v2.3.5
57. Desarrollo guiado por comportamiento (BDD)
con Symfony2, Behat y Mink – Carlos Granados
¡¡Gracias!!
¿Preguntas?
• carlos@planetapluton.com
• @carlos_granados
• http://es.linkedin.com/in/carlosgranados