SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Downloaden Sie, um offline zu lesen
Completing the circle
      Automated web tests as a team communication tool




John Ferguson Smart
So who is this guy, anyway?
               Consulta
                       nt
               Trainer
              Mentor
              Author
             Speaker
             Coder
   John Fer
            guson S
                    mar t
ATDD
or Specification by example




      The story of your app
User stories

As a job seeker
I want to find jobs in relevant categories
So that I can find a suitable job

                                            Features/Epics
User stories

As a job seeker
I want to find jobs in relevant categories
So that I can find a suitable job


                                                                      Acceptance criteria

     ☑	
  The	
  job	
  seeker	
  can	
  see	
  available	
  categories	
  on	
  the	
  home	
  page
     ☑	
  The	
  job	
  seeker	
  can	
  look	
  for	
  jobs	
  in	
  a	
  given	
  category
     ☑	
  The	
  job	
  seeker	
  can	
  see	
  what	
  category	
  a	
  job	
  belongs	
  to
User stories

    As a job seeker
    I want to find jobs in relevant categories
    So that I can find a suitable job


                                                                          Acceptance criteria

         ☑	
  The	
  job	
  seeker	
  can	
  see	
  available	
  categories	
  on	
  the	
  home	
  page
         ☑	
  The	
  job	
  seeker	
  can	
  look	
  for	
  jobs	
  in	
  a	
  given	
  category
         ☑	
  The	
  job	
  seeker	
  can	
  see	
  what	
  category	
  a	
  job	
  belongs	
  to



scenario "A job seeker can see the available job categories on the home page",
{
	   when "the job seeker is looking for a job",
	   then "the job seeker can see all the available job categories"
}

                                                                    Automated acceptance test
scenario "A job seeker can see the available job categories on the home page",
 {
 	   when "the job seeker is looking for a job",
 	   then "the job seeker can see all the available job categories"
 }
                                                      Automated acceptance test




Implemented development tests                         Implemented acceptance tests
Not All Web Tests are Acceptance Tests




  Technical tests are for   Acceptance tests are
      the dev team            for everyone else
Not All Web Tests are Acceptance Tests




  Technical tests talk to   Acceptance tests talk
      the dev team            to everyone else
The art of sustainable web tests




          or how not to have web tests like this
So what are our goals?
Good web tests should




         speak everybody’s language
Good web tests should




           hide unnecessary details
Good web tests should




           use reusable components
Good web tests should




              be low maintenance
The Three Ways of Automated Web Testing




        Record/Replay

      Scripting

Page Objects
Record-replay automated tests




      Promise           Reality
Record-replay automated tests
Script-based automated tests

Selenium RC

      HTMLUnit

              JWebUnit

                     Canoe Webtest

                               Watir
Script-based automated tests

Selenium RC

      HTMLUnit

              JWebUnit

                     Canoe Webtest

                               Watir
How about Page Objects?

Reusable


 Low
 maintenance


  Hide unnecessary detail


                            2
A sample Page Object
                       A web page
A sample Page Object




                                                 A Page Object
                        FindAJobPage



      lookForJobsWithKeywords(values : String)
      getJobTitles() : List<String>
A sample Page Object



  public class FindAJobPage extends PageObject {
                                                                An implemented
      WebElement keywords;
      WebElement searchButton;
                                                                  Page Object
      public FindAJobPage(WebDriver driver) {
          super(driver);
      }

      public void lookForJobsWithKeywords(String values) {
          typeInto(keywords, values);
          searchButton.click();
      }

      public List<String> getJobTitles() {
          List<WebElement> tabs = getDriver()
                           .findElements(By.xpath("//div[@id='jobs']//a"));
          return extract(tabs, on(WebElement.class).getText());
      }
  }
A sample Page Object



  public class WhenSearchingForAJob {

      @Test
      public void searching_for_a_job_should_display_matching_jobs() {
        FindAJobPage page = new FindAJobPage();
        page.open("http://localhost:9000");
        page.lookForJobsWithKeywords("Java");
        assertThat(page.getJobTitles(), hasItem("Java Developer"));
      }
  }
                                                     A test using this
                                                       Page Object
Sustainable web tests




                        Are we there yet?
Acceptance Tests

The high-level view




  So	
  where	
  are	
  
        we	
  at?
Page Objects

           Page	
  Objects	
  
              rock!




           Implementation focus
How do we bridge the gap?
How do we bridge the gap?




                 Test steps
scenario "A job seeker can see the available job categories on the home page",
    {
    	   when "the job seeker is looking for a job",
    	   then "the job seeker can see all the available job categories"
    }
                                                                           Automated

scenario "The user can see the available job categories on the home page",
{
	   when "the job seeker is looking for a job",
    {
       job_seeker.open_jobs_page()
    }
	   then "the job seeker can see all the available job categories",
    {
       job_seeker.should_see_job_categories "Java Developers", "Groovy Developers"
    }
}
                                                                           Implemented

                  JobSeekerSteps
                    JobSeekerSteps
                      JobSeekerSteps
                  open_jobs_page()
                    open_jobs_page()
                      open_jobs_page()
                  should_see_job_categories(String...	
  categories)
                    should_see_job_categories(String...	
  categories)
                  ... should_see_job_categories(String...	
  categories)
                    ...
                      ...
                                                    Step libraries
scenario "The user can see the available job categories on the home page",
{
	   when "the job seeker is looking for a job",
    {
       job_seeker.open_jobs_page()
    }
	   then "the job seeker can see all the available job categories",
    {
       job_seeker.should_see_job_categories "Java Developers", "Groovy Developers"
    }
}

                                                                             Implemented Tests

                      JobSeekerSteps
                        JobSeekerSteps
                          JobSeekerSteps
                      open_jobs_page()
                        open_jobs_page()
                          open_jobs_page()
                      should_see_job_categories(String...	
  categories)
                        should_see_job_categories(String...	
  categories)
                      ... should_see_job_categories(String...	
  categories)
                        ...
                          ...
                                                                       Step libraries




                                                                            Page Objects
Test steps




        help organize your tests
Test steps




are a communication tool
Test steps




     are reusable building blocks
Test steps




help estimate progress
And so we built a tool...
Webdriver/Selenium 2 extension

Organize tests, stories and features




                               Record/report test execution


              Measure functional coverage
Thucydides in action   A simple demo app
Defining your acceptance tests
  scenario "A
              job seeker
  {                       can see the
                                       available j
                                                       ob categori
 	   when "the j                                                   es on the h
                 ob seeker i                                                   ome page",
 	   then "the j             s looking f
                 ob seeker c             o r a j o b ",
 }                           an see all
                                        the availab
                                                        le job cate
                                                                    gories"

                                                        High level requ
                                                                                 irements...

                  scenario "The administrator adds a new category to the system",
                  {
                      given "a new category needs to be added to the system",
                      when "the administrator adds a new category",
                      then "the system should confirm that the category has been created",
                      and "the new category should be visible to job seekers",
                  }

 {
  scenario "The admini
                       strator deletes a ca
                                            tegory from the syst
                                                                 em",
                                                                                ...defined in business terms
      given "a category ne
                           eds to be deleted",
      when "the administra
                           tor deletes a catego
      then "the system will                     ry",
                             confirm that the cate
      and "the deleted cate                        gory has been delete
                            gory should no longer                       d",
 }                                                 be visible to job se
                                                                        eker   s",

                                           focus on business value
Organizing your requirements
 Features   public class Application {

                @Feature
                public class ManageCompanies {
                    public class AddNewCompany {}
                    public class DeleteCompany {}
                    public class ListCompanies {}
                }

                @Feature
                public class ManageCategories {
                    public class AddNewCategory {}
                    public class ListCategories {}
                    public class DeleteCategory {}
                }

                @Feature                                 Stories
                public class BrowseJobs {
                    public class UserLookForJobs {}
                    public class UserBrowsesJobTabs {}
                }
            }
Implementing your acceptance tests
using "thucydides"                                   We are testing this story
thucydides.uses_steps_from AdministratorSteps
thucydides.uses_steps_from JobSeekerSteps
thucydides.tests_story AddNewCategory
                                                          An acceptance criteria
scenario "The administrator adds a new category to the system",
{
	 given "a new category needs to be added to the system",
    {
                                                                 Narrative style
      administrator.logs_in_to_admin_page_if_first_time()
      administrator.opens_categories_list()
    }                                                              Step through an
	 when "the administrator adds a new category",                       example
    {
       administrator.selects_add_category()
       administrator.adds_new_category("Scala Developers","SCALA")
    }
    then "the system should confirm that the category has been created",
    {
        administrator.should_see_confirmation_message "The Category has been created"
    }
    and "the new category should be visible to job seekers",
    {                                                              Still high-level
        job_seeker.opens_jobs_page()
        job_seeker.should_see_job_category "Scala Developers"
    }
}
Some folks prefer JUnit...
@RunWith(ThucydidesRunner.class)
@Story(AddNewCategory.class)                      Thucydides handles the
public class AddCategoryStory {
                                                   web driver instances
    @Managed
    public WebDriver webdriver;

    @ManagedPages(defaultUrl = "http://localhost:9000")
    public Pages pages;

    @Steps
    public AdministratorSteps administrator;

    @Steps
                                                                 Using the same steps
    public JobSeekerSteps job_seeker;

    @Test
    public void administrator_adds_a_new_category_to_the_system() {
        administrator.logs_in_to_admin_page_if_first_time();
        administrator.opens_categories_list();
        administrator.selects_add_category();
        administrator.adds_new_category("Java Developers","JAVA");
        administrator.should_see_confirmation_message("The Category has been created");

        job_seeker.opens_job_page();
        job_seeker.should_see_job_category("Java Developers");
    }                                                              Tests can be pending
    @Pending @Test
    public void administrator_adds_an_existing_category_to_the_system() {}
}
Defining your test steps
public class AdministratorSteps extends ScenarioSteps {                  A step library
    @Step
    public void opens_categories_list() {
        AdminHomePage page = getPages().get(AdminHomePage.class);
        page.open();
        page.selectObjectType("Categories");
    }                                                               High level steps...
    @Step
    public void selects_add_category() {
        CategoriesPage categoriesPage = getPages().get(CategoriesPage.class);
        categoriesPage.selectAddCategory();
    }

    @Step
    public void adds_new_category(String label, String code) {
        EditCategoryPage newCategoryPage = getPages().get(EditCategoryPage.class);
        newCategoryPage.saveNewCategory(label, code);
    }
                                                                         ...implemented
    @Step
    public void should_see_confirmation_message(String message) {
                                                                        with Page Objects
        AdminPage page = getPages().get(AdminPage.class);
        page.shouldContainConfirmationMessage(message);
    }

    @StepGroup                                                        ...or with other steps
    public void deletes_category(String name) {
        opens_categories_list();
        displays_category_details_for(name);
        deletes_category();
    }
}
Defining your page objects
public class EditCategoryPage extends PageObject {

    @FindBy(id="object_label")
    WebElement label;                                 Provides some useful
    @FindBy(id="object_code")
                                                        utility methods...
    WebElement code;

    @FindBy(name="_save")
    WebElement saveButton;

    public EditCategoryPage(WebDriver driver) {
        super(driver);
    }

    public void saveNewCategory(String labelValue, String codeValue) {
        typeInto(label, labelValue);
        typeInto(code, codeValue);
        saveButton.click();
    }
}                                      but otherwise a normal
                                       WebDriver Page Object
Data-driven testing
                                                Test data



             categories.csv

public class DataDrivenCategorySteps extends ScenarioSteps {
                                                               Test steps
    public DataDrivenCategorySteps(Pages pages) {
        super(pages);
    }

    private String name;
    private String code;

    @Steps
    public AdminSteps adminSteps;

    public void setCode(String code) {...}
    public void setName(String name) {...}

    @Step
    public void add_a_category() {
        adminSteps.add_category(name, code);
    }
}
Data-driven testing
                                                Test data



             categories.csv

public class DataDrivenCategorySteps extends ScenarioSteps {
                                                                 Test steps
    public DataDrivenCategorySteps(Pages pages) {
        super(pages);
    }

    private String name;
    private String code;

    @Steps
    public AdminSteps adminSteps;

             @Steps
    public void setCode(String code) {...}
              public DataDrivenCategorySteps categorySteps;
    public void setName(String name) {...}

    @Step     @Test
    public void add_a_category() {
                                                                  Call this step for
              public void adding_multiple_categories() throws IOException {
        adminSteps.add_category(name, code);
                  steps.login_to_admin_page_if_first_time();
}
    }
                  steps.open_categories_list();                       each row
                  withTestDataFrom("categories.csv").run(categorySteps).add_a_category();
             }
Now run your tests
Displaying the results in easyb
Displaying the results in easyb
Thucydides reports

               Browse the features
Browse the stories

            Browse the stories
Browse the stories

               Browse the test scenarios
Illustrating the test paths
                                    A test
                                   scenario




                                   Steps




                         Test
                       scenarios
Illustrating the test paths
                                           Test
                                         scenario




                                         Steps




                         Test
                       scenarios


                                   Screenshots
Functional coverage




                      Features
Functional coverage




                       User
                      stories
Functional coverage

                      Passing tests




                            Pending tests
Progress
Functional coverage




                        Test
                      scenarios
Functional coverage
References
           easyb.org



    github.com/thucydides-webtests




                 wakaleo.com/thucydides
The Circle is Complete
 Automated web tests as a team communication tool




                                        John	
  Ferguson	
  Smart
                         Email:	
  john.smart@wakaleo.com
                          Web:	
  hCp://www.wakaleo.com
                                            TwiCer:	
  wakaleo

Weitere ähnliche Inhalte

Andere mochten auch

Understanding Social Media for Business
Understanding Social Media for BusinessUnderstanding Social Media for Business
Understanding Social Media for BusinessSite-Seeker, Inc.
 
Resume Mcgregor March 2016
Resume Mcgregor March 2016Resume Mcgregor March 2016
Resume Mcgregor March 2016Arthur McGregor
 
Ashtavakra Gita - Chapter 3 - Test of the Seeker
Ashtavakra Gita - Chapter 3 - Test of the SeekerAshtavakra Gita - Chapter 3 - Test of the Seeker
Ashtavakra Gita - Chapter 3 - Test of the SeekerVinod Kad
 
Recherche d'emploi et réseaux sociaux
Recherche d'emploi et réseaux sociauxRecherche d'emploi et réseaux sociaux
Recherche d'emploi et réseaux sociauxWebpatron
 
Innovacio Oberta portada a la practica (UOC)
Innovacio Oberta portada a la practica (UOC)Innovacio Oberta portada a la practica (UOC)
Innovacio Oberta portada a la practica (UOC)Induct SEA
 
TDNN for speech recognition
TDNN for speech recognitionTDNN for speech recognition
TDNN for speech recognitionVíctor Pacheco
 
Particle swarm optimization for human face recognition
Particle swarm optimization for human face recognitionParticle swarm optimization for human face recognition
Particle swarm optimization for human face recognitionCIMAT
 
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicos
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicosTecnologia de Imagenes (OCR) y Seguridad de datos electrónicos
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicosDigetech.net
 
Destrezas BáSicas De Registro De Datos Financieros
Destrezas BáSicas De Registro De Datos FinancierosDestrezas BáSicas De Registro De Datos Financieros
Destrezas BáSicas De Registro De Datos FinancierosCarmen Maldonado
 
Personal Branding 2.0
Personal Branding 2.0Personal Branding 2.0
Personal Branding 2.0Elena Faba
 
Reconocimiento supramolecular del ADN
Reconocimiento supramolecular del ADNReconocimiento supramolecular del ADN
Reconocimiento supramolecular del ADNMar Sánchez
 
Demanda - MeliDevConf BsAs.
Demanda - MeliDevConf BsAs.Demanda - MeliDevConf BsAs.
Demanda - MeliDevConf BsAs.melidevelopers
 

Andere mochten auch (16)

Understanding Social Media for Business
Understanding Social Media for BusinessUnderstanding Social Media for Business
Understanding Social Media for Business
 
Missles flight control systems
Missles flight control systemsMissles flight control systems
Missles flight control systems
 
Resume Mcgregor March 2016
Resume Mcgregor March 2016Resume Mcgregor March 2016
Resume Mcgregor March 2016
 
Dream project
Dream projectDream project
Dream project
 
Ashtavakra Gita - Chapter 3 - Test of the Seeker
Ashtavakra Gita - Chapter 3 - Test of the SeekerAshtavakra Gita - Chapter 3 - Test of the Seeker
Ashtavakra Gita - Chapter 3 - Test of the Seeker
 
handwriting recognition
handwriting recognitionhandwriting recognition
handwriting recognition
 
Recherche d'emploi et réseaux sociaux
Recherche d'emploi et réseaux sociauxRecherche d'emploi et réseaux sociaux
Recherche d'emploi et réseaux sociaux
 
Innovacio Oberta portada a la practica (UOC)
Innovacio Oberta portada a la practica (UOC)Innovacio Oberta portada a la practica (UOC)
Innovacio Oberta portada a la practica (UOC)
 
TDNN for speech recognition
TDNN for speech recognitionTDNN for speech recognition
TDNN for speech recognition
 
Fiera Presentation
Fiera   PresentationFiera   Presentation
Fiera Presentation
 
Particle swarm optimization for human face recognition
Particle swarm optimization for human face recognitionParticle swarm optimization for human face recognition
Particle swarm optimization for human face recognition
 
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicos
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicosTecnologia de Imagenes (OCR) y Seguridad de datos electrónicos
Tecnologia de Imagenes (OCR) y Seguridad de datos electrónicos
 
Destrezas BáSicas De Registro De Datos Financieros
Destrezas BáSicas De Registro De Datos FinancierosDestrezas BáSicas De Registro De Datos Financieros
Destrezas BáSicas De Registro De Datos Financieros
 
Personal Branding 2.0
Personal Branding 2.0Personal Branding 2.0
Personal Branding 2.0
 
Reconocimiento supramolecular del ADN
Reconocimiento supramolecular del ADNReconocimiento supramolecular del ADN
Reconocimiento supramolecular del ADN
 
Demanda - MeliDevConf BsAs.
Demanda - MeliDevConf BsAs.Demanda - MeliDevConf BsAs.
Demanda - MeliDevConf BsAs.
 

Mehr von John Ferguson Smart Limited

My Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosMy Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosJohn Ferguson Smart Limited
 
Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...John Ferguson Smart Limited
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceJohn Ferguson Smart Limited
 
Sustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplaySustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplayJohn Ferguson Smart Limited
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceJohn Ferguson Smart Limited
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...John Ferguson Smart Limited
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...John Ferguson Smart Limited
 
Screenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingScreenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingJohn Ferguson Smart Limited
 
All the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesAll the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesJohn Ferguson Smart Limited
 
It's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersIt's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersJohn Ferguson Smart Limited
 

Mehr von John Ferguson Smart Limited (20)

My Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosMy Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin Scenarios
 
Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a difference
 
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANTBE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
 
Sustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplaySustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and Screenplay
 
Feature Mapping Workshop
Feature Mapping WorkshopFeature Mapping Workshop
Feature Mapping Workshop
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a difference
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
 
Shift left-devoxx-pl
Shift left-devoxx-plShift left-devoxx-pl
Shift left-devoxx-pl
 
Screenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingScreenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testing
 
Cucumber and Spock Primer
Cucumber and Spock PrimerCucumber and Spock Primer
Cucumber and Spock Primer
 
All the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesAll the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practices
 
CukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning WorkshopCukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning Workshop
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
Serenity and the Journey Pattern
Serenity and the Journey PatternSerenity and the Journey Pattern
Serenity and the Journey Pattern
 
BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!
 
BDD-Driven Microservices
BDD-Driven MicroservicesBDD-Driven Microservices
BDD-Driven Microservices
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
It's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersIt's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for Testers
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Completing the circle - Automated web tests as a team communication tool

  • 1. Completing the circle Automated web tests as a team communication tool John Ferguson Smart
  • 2. So who is this guy, anyway? Consulta nt Trainer Mentor Author Speaker Coder John Fer guson S mar t
  • 3. ATDD or Specification by example The story of your app
  • 4. User stories As a job seeker I want to find jobs in relevant categories So that I can find a suitable job Features/Epics
  • 5. User stories As a job seeker I want to find jobs in relevant categories So that I can find a suitable job Acceptance criteria ☑  The  job  seeker  can  see  available  categories  on  the  home  page ☑  The  job  seeker  can  look  for  jobs  in  a  given  category ☑  The  job  seeker  can  see  what  category  a  job  belongs  to
  • 6. User stories As a job seeker I want to find jobs in relevant categories So that I can find a suitable job Acceptance criteria ☑  The  job  seeker  can  see  available  categories  on  the  home  page ☑  The  job  seeker  can  look  for  jobs  in  a  given  category ☑  The  job  seeker  can  see  what  category  a  job  belongs  to scenario "A job seeker can see the available job categories on the home page", { when "the job seeker is looking for a job", then "the job seeker can see all the available job categories" } Automated acceptance test
  • 7. scenario "A job seeker can see the available job categories on the home page", { when "the job seeker is looking for a job", then "the job seeker can see all the available job categories" } Automated acceptance test Implemented development tests Implemented acceptance tests
  • 8. Not All Web Tests are Acceptance Tests Technical tests are for Acceptance tests are the dev team for everyone else
  • 9. Not All Web Tests are Acceptance Tests Technical tests talk to Acceptance tests talk the dev team to everyone else
  • 10. The art of sustainable web tests or how not to have web tests like this
  • 11. So what are our goals?
  • 12. Good web tests should speak everybody’s language
  • 13. Good web tests should hide unnecessary details
  • 14. Good web tests should use reusable components
  • 15. Good web tests should be low maintenance
  • 16. The Three Ways of Automated Web Testing Record/Replay Scripting Page Objects
  • 17. Record-replay automated tests Promise Reality
  • 19. Script-based automated tests Selenium RC HTMLUnit JWebUnit Canoe Webtest Watir
  • 20. Script-based automated tests Selenium RC HTMLUnit JWebUnit Canoe Webtest Watir
  • 21. How about Page Objects? Reusable Low maintenance Hide unnecessary detail 2
  • 22. A sample Page Object A web page
  • 23. A sample Page Object A Page Object FindAJobPage lookForJobsWithKeywords(values : String) getJobTitles() : List<String>
  • 24. A sample Page Object public class FindAJobPage extends PageObject { An implemented WebElement keywords; WebElement searchButton; Page Object public FindAJobPage(WebDriver driver) { super(driver); } public void lookForJobsWithKeywords(String values) { typeInto(keywords, values); searchButton.click(); } public List<String> getJobTitles() { List<WebElement> tabs = getDriver() .findElements(By.xpath("//div[@id='jobs']//a")); return extract(tabs, on(WebElement.class).getText()); } }
  • 25. A sample Page Object public class WhenSearchingForAJob { @Test public void searching_for_a_job_should_display_matching_jobs() { FindAJobPage page = new FindAJobPage(); page.open("http://localhost:9000"); page.lookForJobsWithKeywords("Java"); assertThat(page.getJobTitles(), hasItem("Java Developer")); } } A test using this Page Object
  • 26. Sustainable web tests Are we there yet?
  • 27. Acceptance Tests The high-level view So  where  are   we  at?
  • 28. Page Objects Page  Objects   rock! Implementation focus
  • 29. How do we bridge the gap?
  • 30. How do we bridge the gap? Test steps
  • 31. scenario "A job seeker can see the available job categories on the home page", { when "the job seeker is looking for a job", then "the job seeker can see all the available job categories" } Automated scenario "The user can see the available job categories on the home page", { when "the job seeker is looking for a job", { job_seeker.open_jobs_page() } then "the job seeker can see all the available job categories", { job_seeker.should_see_job_categories "Java Developers", "Groovy Developers" } } Implemented JobSeekerSteps JobSeekerSteps JobSeekerSteps open_jobs_page() open_jobs_page() open_jobs_page() should_see_job_categories(String...  categories) should_see_job_categories(String...  categories) ... should_see_job_categories(String...  categories) ... ... Step libraries
  • 32. scenario "The user can see the available job categories on the home page", { when "the job seeker is looking for a job", { job_seeker.open_jobs_page() } then "the job seeker can see all the available job categories", { job_seeker.should_see_job_categories "Java Developers", "Groovy Developers" } } Implemented Tests JobSeekerSteps JobSeekerSteps JobSeekerSteps open_jobs_page() open_jobs_page() open_jobs_page() should_see_job_categories(String...  categories) should_see_job_categories(String...  categories) ... should_see_job_categories(String...  categories) ... ... Step libraries Page Objects
  • 33. Test steps help organize your tests
  • 34. Test steps are a communication tool
  • 35. Test steps are reusable building blocks
  • 37. And so we built a tool...
  • 38. Webdriver/Selenium 2 extension Organize tests, stories and features Record/report test execution Measure functional coverage
  • 39.
  • 40. Thucydides in action A simple demo app
  • 41. Defining your acceptance tests scenario "A job seeker { can see the available j ob categori when "the j es on the h ob seeker i ome page", then "the j s looking f ob seeker c o r a j o b ", } an see all the availab le job cate gories" High level requ irements... scenario "The administrator adds a new category to the system", { given "a new category needs to be added to the system", when "the administrator adds a new category", then "the system should confirm that the category has been created", and "the new category should be visible to job seekers", } { scenario "The admini strator deletes a ca tegory from the syst em", ...defined in business terms given "a category ne eds to be deleted", when "the administra tor deletes a catego then "the system will ry", confirm that the cate and "the deleted cate gory has been delete gory should no longer d", } be visible to job se eker s", focus on business value
  • 42. Organizing your requirements Features public class Application { @Feature public class ManageCompanies { public class AddNewCompany {} public class DeleteCompany {} public class ListCompanies {} } @Feature public class ManageCategories { public class AddNewCategory {} public class ListCategories {} public class DeleteCategory {} } @Feature Stories public class BrowseJobs { public class UserLookForJobs {} public class UserBrowsesJobTabs {} } }
  • 43. Implementing your acceptance tests using "thucydides" We are testing this story thucydides.uses_steps_from AdministratorSteps thucydides.uses_steps_from JobSeekerSteps thucydides.tests_story AddNewCategory An acceptance criteria scenario "The administrator adds a new category to the system", { given "a new category needs to be added to the system", { Narrative style administrator.logs_in_to_admin_page_if_first_time() administrator.opens_categories_list() } Step through an when "the administrator adds a new category", example { administrator.selects_add_category() administrator.adds_new_category("Scala Developers","SCALA") } then "the system should confirm that the category has been created", { administrator.should_see_confirmation_message "The Category has been created" } and "the new category should be visible to job seekers", { Still high-level job_seeker.opens_jobs_page() job_seeker.should_see_job_category "Scala Developers" } }
  • 44. Some folks prefer JUnit... @RunWith(ThucydidesRunner.class) @Story(AddNewCategory.class) Thucydides handles the public class AddCategoryStory { web driver instances @Managed public WebDriver webdriver; @ManagedPages(defaultUrl = "http://localhost:9000") public Pages pages; @Steps public AdministratorSteps administrator; @Steps Using the same steps public JobSeekerSteps job_seeker; @Test public void administrator_adds_a_new_category_to_the_system() { administrator.logs_in_to_admin_page_if_first_time(); administrator.opens_categories_list(); administrator.selects_add_category(); administrator.adds_new_category("Java Developers","JAVA"); administrator.should_see_confirmation_message("The Category has been created"); job_seeker.opens_job_page(); job_seeker.should_see_job_category("Java Developers"); } Tests can be pending @Pending @Test public void administrator_adds_an_existing_category_to_the_system() {} }
  • 45. Defining your test steps public class AdministratorSteps extends ScenarioSteps { A step library @Step public void opens_categories_list() { AdminHomePage page = getPages().get(AdminHomePage.class); page.open(); page.selectObjectType("Categories"); } High level steps... @Step public void selects_add_category() { CategoriesPage categoriesPage = getPages().get(CategoriesPage.class); categoriesPage.selectAddCategory(); } @Step public void adds_new_category(String label, String code) { EditCategoryPage newCategoryPage = getPages().get(EditCategoryPage.class); newCategoryPage.saveNewCategory(label, code); } ...implemented @Step public void should_see_confirmation_message(String message) { with Page Objects AdminPage page = getPages().get(AdminPage.class); page.shouldContainConfirmationMessage(message); } @StepGroup ...or with other steps public void deletes_category(String name) { opens_categories_list(); displays_category_details_for(name); deletes_category(); } }
  • 46. Defining your page objects public class EditCategoryPage extends PageObject { @FindBy(id="object_label") WebElement label; Provides some useful @FindBy(id="object_code") utility methods... WebElement code; @FindBy(name="_save") WebElement saveButton; public EditCategoryPage(WebDriver driver) { super(driver); } public void saveNewCategory(String labelValue, String codeValue) { typeInto(label, labelValue); typeInto(code, codeValue); saveButton.click(); } } but otherwise a normal WebDriver Page Object
  • 47. Data-driven testing Test data categories.csv public class DataDrivenCategorySteps extends ScenarioSteps { Test steps public DataDrivenCategorySteps(Pages pages) { super(pages); } private String name; private String code; @Steps public AdminSteps adminSteps; public void setCode(String code) {...} public void setName(String name) {...} @Step public void add_a_category() { adminSteps.add_category(name, code); } }
  • 48. Data-driven testing Test data categories.csv public class DataDrivenCategorySteps extends ScenarioSteps { Test steps public DataDrivenCategorySteps(Pages pages) { super(pages); } private String name; private String code; @Steps public AdminSteps adminSteps; @Steps public void setCode(String code) {...} public DataDrivenCategorySteps categorySteps; public void setName(String name) {...} @Step @Test public void add_a_category() { Call this step for public void adding_multiple_categories() throws IOException { adminSteps.add_category(name, code); steps.login_to_admin_page_if_first_time(); } } steps.open_categories_list(); each row withTestDataFrom("categories.csv").run(categorySteps).add_a_category(); }
  • 49. Now run your tests
  • 52. Thucydides reports Browse the features
  • 53. Browse the stories Browse the stories
  • 54. Browse the stories Browse the test scenarios
  • 55. Illustrating the test paths A test scenario Steps Test scenarios
  • 56. Illustrating the test paths Test scenario Steps Test scenarios Screenshots
  • 58. Functional coverage User stories
  • 59. Functional coverage Passing tests Pending tests
  • 61. Functional coverage Test scenarios
  • 63. References easyb.org github.com/thucydides-webtests wakaleo.com/thucydides
  • 64. The Circle is Complete Automated web tests as a team communication tool John  Ferguson  Smart Email:  john.smart@wakaleo.com Web:  hCp://www.wakaleo.com TwiCer:  wakaleo