SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
BDD BRZMI PIĘKNIE.
TYLKO DLACZEGO CZĘSTO SIE NIE UDAJE?
@tommykaczmarek
@SCENARIO
@Given
@When
@Then
Scenario Aktywacja karty
Given Użytkownik ma nieaktywną karte
When Użytkownik aktywuje karte podając $pin
Then Aktywacja ma status $status i zostanie wyświelony komunikat $komunikat
Examples:
| pin      | status | komunikat                                |
| 2244     | OK     | Ustawienie kodu PIN przebiegło pomyślnie |
| 22a2     | FAIL   | Dozwolone tylko liczby                   |
| 62628812 | FAIL   | Długość kodu PIN powinna wynosić 4 znaki |
public class CardActivationSteps {
    private BankCardApi bankCardApi;
    private BankCard bankCard;
    public CardActivationSteps(BankCardApi bankCardApi) {
        this.bankCardApi = bankCardApi;
    }
    @Given("Użytkownik ma nieaktywną karte")
    public void cardIsInactive() {
        bankCard = bankCardApi.prepareNewCard();
    }
    @When("Użytkownik aktywuje karte podając $pin")
    public void cardIsUsedForAFirstTime(@Named("pin") String pin) {
        bankCardApi.activate(bankCard, pin);
    }
    @Then("Aktywacja ma status $status i zostanie wyświelony komunikat $komunikat")
    public void pinGenerationRequest(@Named("status") String status, 
            @Named("komunikat") String komunikat) {
        ActivationResult activationResult = bankCardApi.activationStatus(bankCard);
        assertThat(activationResult.getStatus().name()).isEqualTo(status);
        assertThat(activationResult.getError()).isEqualTo(komunikat);
    }
}
         
Scenario Użytkownik zakłada konto w serwisie
Given Użytkownik zakłada konto
When Użytkownik poda imie $imie oraz nazwisko $nazwisko
Then Operacja ma status $status i zostanie wyświetlony komunikat $komunikat
And Zostanie wyświetlony błąd : Nieprawidłowo wypełniony formularz
Examples:
| imie   | nazwisko   | status | komunikat               |
| Tomasz | Kaczmarek# | FAIL   | Formularz zawiera błędy |
KOMUNIKACJA
DYSKUSJA
PRZEJRZYSTOŚĆ
SPISYWANIE
SCENARIUSZY
A WIĘC CHCESZ UŻYĆ W PROJEKCIE
BDD...
“Mamy scruma ale nie robimy standupów
bo nie mamy problemów z komunikacją”
DLACZEGO CHCĘ UŻYWAĆ NOWEGO
NARZĘDZIA
Co chcę osiągnąć?
Jak będę mierzyć efektywność?
“Przecież to prawie jak mamy u siebie”
“Analityk będzie pisać scenariusze w
formule Given/When/Then”
SPECYFIKACJE SĄ
SPISYWANE
“To taki inny sposób na skrypty testowe”
Scenario ­ Zmiana miasta w profilu użytkownika
Given Użytkownik zaloguje się do serwisu jako zenon 
And Wprowadzi hasło zenon1
And Kliknie na zakładke Ustawienia
And Przejdzie do Zaawansowane
And Przejdzie do sekcji profil
When Naciśnie przycisk edytuj profil
Then Zostanie przekierowany do strony edycji profilu
When Wprowadzi miasto zamieszkania
And Naciśnie zapisz
Then Profil zostanie zapisany
And Wyświetli sie informacja: Profil zapisany
WARUNKI BRZEGOWE
Scenario Użytkownik zakłada konto w serwisie
Given Użytkownik zakłada konto
When Użytkownik poda imie $imie oraz nazwisko $nazwisko
Then Operacja ma status $status i zostanie wyświetlony komunikat $komunikat
And Zostanie wyświetlony błąd : Nieprawidłowo wypełniony formularz
Examples:
| imie     | nazwisko    | status | komunikat               |
| Tomasz   | Kaczmarek#  | FAIL   | Formularz zawiera błędy |
| Tomasz@  | Kaczmarek   | FAIL   | Formularz zawiera błędy |
| Tomasz   | Kaczmarek11 | FAIL   | Formularz zawiera błędy |
| Tomasz23 | Kaczmarek   | FAIL   | Formularz zawiera błędy |
| Tomasz   | Kaczmarek_  | FAIL   | Formularz zawiera błędy |
| Tomasz^  | Kaczmarek   | FAIL   | Formularz zawiera błędy |
| Tomasz   | Kaczmarek%  | FAIL   | Formularz zawiera błędy |
| Tomasz   | (Kaczmarek) | FAIL   | Formularz zawiera błędy |   
           
NAZYWAJ SYTUACJE
DOSŁOWNIE
Given Gateway nie otrzyma ramki RFVS przez 30 sekund
And Gateway nie może wysłać ramki H3DE do mediatora
When Użytkownik wykona akcje ROZPOZNAJ
Then Na ekranie wyświetli sie: System nie działa, sprobuj później.
Given Mediator jest rozłączony
When Użytkownik wykona akcje ROZPOZNAJ
Then Na ekranie wyświetli sie: System nie działa, sprobuj później.
“Ten scenariusz jest bardzo podobny do
poprzedniego. Utworzymy sobie wspólną
baze początkowych kroków dla
scenariuszy.”
“Współdzielenie kodu!”
DOBRE INTENCJE.
NIEKONTROLOWANE KOPIOWANIE.
OBSZERNE KROKI USTAWIAJĄCE
SYSTEM
“Scenariusze będą uaktualniane w
następnym sprincie po wdrożeniu na
produkcje.”
CZY KTOŚ BĘDZIE
CZYTAĆ
SPECYFIKACJE?
...PO NAPISANIU
NIECZYTANE = NIECZYTELNE
BARDZO SZYBKO..
KTO BĘDZIE ODBIORCĄ
SPECYFIKACJI?
DEVELOPERZY LEPIEJ
ZROZUMIEJĄ TESTY
“Na unit testy nie ma czasu bo mamy
JBehave.”
TESTY Z
NASTAWIENIEM NA
ZACHOWANIE
def "should activate inactive banking card"() {
    given: "Użytkownik ma nieaktywną karte"
    bankCard = bankCardApi.prepareNewCard();
    when: "Użytkownik aktywuje karte podając pin"
    bankCardApi.activate(bankCard, pin);
    then: "Aktywacja ma status status i zostanie wyświelony komunikat komunikat"
    ActivationResult activationResult = bankCardApi.activationStatus(bankCard);
    activationResult.getStatus().name() == status
    activationResult.getError() == message
    where:
        pin    | status     | message
        "2244" | "OK"       | "Ustawienie kodu PIN przebiegło pomyślnie"
        "22a2" | "FAIL"     | "Dozwolone tylko liczby"
    "62628812" | "FAIL"     | "Długość kodu PIN powinna wynosić 4 znaki"
}
           
KOMUNIKACJA
SPISYWANIE SPECYFIKACJI
CZYTANIE SPECYFIKACJI
SPECYFIKACJA VS TESTY
PYTANIA?

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

4Developers 2015: Behavior Driven Development - sounds perfect but why are we failing? - Tomasz Kaczmarek