SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
ОСОБЕННОСТИ
       АВТОМАТИЗАЦИИ ТЕСТИРОВАНИЯ
       Single-page vs. Multi-page

                                         Татьяна Курносова
                                            t.kurnosova@2gis.ru




      1-2 марта 2013 г., Киев, Украина
Saturday, 2 January, 13
2ГИС СЕГОДНЯ


•    > 200 городов
     (Новосибирск, Москва, Одесса, Падуя, …)
•    4 страны (Россия, Казахстан, Украина, Италия)
•    > 20 млн. пользователей (desktop, online, mobile)




     WWW.2GIS.RU


Saturday, 2 January, 13
ТЕСТИРОВАНИЕ В 2ГИС

                                    Quality Assurance


                          2GIS Online
                           QA Team
                                                    Developer
                                    2GIS API
                                                     in Test
                                    QA Team           Team


                           Flamp
                          QA Team




     WWW.2GIS.RU


Saturday, 2 January, 13
ТЕСТИРОВАНИЕ В 2ГИС

                                            Quality Assurance


                                  2GIS Online
    Ручное и автоматизированное




                                   QA Team
                                                               Developer
                                            2GIS API
                                                                in Test
                                            QA Team              Team
    тестирование




                                   Flamp
                                  QA Team
                                                       •   Разработка фреймворков
                                                       •   Обучение тестировщиков


        WWW.2GIS.RU


Saturday, 2 January, 13
ИСТОРИЯ РОЖДЕНИЯ ФРЕЙМВОРКОВ
                          maps.2gis.ru                        flamp.ru

                                    Single-page                       Multi-page




        Электронный справочник (карты +
        справочный контент)                       Сервис отзывов о компаниях
                                                  городов России

                          Поставщиком справочных данных является
                            сервис справочного API (api.2gis.ru)

     WWW.2GIS.RU


Saturday, 2 January, 13
ИСТОРИЯ РОЖДЕНИЯ ФРЕЙМВОРКОВ
                          maps.2gis.ru                  flamp.ru




             Автоматизация тестирования продуктов
        •   Создать фреймворки для автоматизации тестирования двух
            продуктов (SPA и MPA)

        •   Покрыть базовый функционал автотестами
        •   Single-Page Application (SPA)
            за минимальное время
                                           • Multi-Page Application (MPA)



     WWW.2GIS.RU


Saturday, 2 January, 13
ТРЕБОВАНИЯ К ТЕСТОВЫМ ФРЕЙМВОРКАМ


                             •   Простая архитектура – лёгкость в освоении
                                 для тестировщиков
     Архитектурный стиль
      KISS – Keep It Short
                             •   Компактные тесты – минимум LOC
          and Simple
                             •   Устойчивость к изменениям, расширяемость




     WWW.2GIS.RU


Saturday, 2 January, 13
ИНСТРУМЕНТЫ


                                        Tests


                          Framework



                     PHPUnit_Selenium


                            Selenium




     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT




       Web Page            Page Class   Test
       <html>              class { }    class { }
       </html>




     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT
     Authentification Page
                             class AuthentificationPage
                             {
                                 public function __construct($test)
                                 {
                                     $this->emailInput =
                                        $test->byName('email');
                                     /* ... */
                                 }

                                 public function email($value)
                                 {
                                     $this->emailInput->value($value);
                                     return $this;
                                 }
                                 /* ... */
                             }



     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT

    public function testAuthentification()
    {
        $this->url('/test_login_page.html');
        $page = new AuthentificationPage($this);
        $homePage = $page->email('test@2gis.ru')
                              ->password('TestPassword')
                              ->submit();
        $this->assertEquals('Welcome, Test!',
                          $homePage->welcomeText();
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
FLAMP.RU




     WWW.2GIS.RU


Saturday, 2 January, 13
FLAMP.RU




                          Этапы автоматизации
        •   Базовый функционал продукта

        •   Специализированная сборка, исключающая зависимость от дизайна




     WWW.2GIS.RU


Saturday, 2 January, 13
Saturday, 2 January, 13
.




Saturday, 2 January, 13
.




Saturday, 2 January, 13
PAGE COMPONENT

    class ReviewForm()
    {
        public function __construct($test)
        {
            $this->reviewText = $test->byId('at_text');
            $this->reviewRating = $test->byId('at_rating');
            $this->reviewSubmit = $test->byId('at_submit');
        }

            public function fill($text, $rating)
            {
                $this->reviewText->value($text);
                $this->reviewRating->value($rating);
            }

            public function submit()
            /* ... */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT

    class ReviewPage
    {
        public function __construct($test)
        {
            $this->authForm = $this->getAuthForm();
            $this->reviewForm = $this->getReviewForm();
            $this->reviewsList = $this->getReviewsList();
            /* ... */
        }

            public function addReview($text, $rating)
            {
                $this->reviewForm->fill($text, $rating);
                $this->reviewForm->submit();
                return $this;
            }
            /* ... */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА”

    public function testAddReviewAndCheckInTheList()
    {
            $this->url('...');
            $page = new ReviewPage();
            $count = $page->getReviewsCount();
            $page = $page->addReview($text, $rating);
            $this->assertEquals(
                          $count + 1,
                          $page->getReviewsCount()
              );
            /* other asserts */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА”

    public function testAddReviewAndCheckInTheList()
    {
            $this->url('...');
            $page = new ReviewPage();
            $count = $page->getReviewsCount();
            $page = $page->addReview($text, $rating);
            $this->assertEquals(
                          $count + 1,
                          $page->getReviewsCount()
              );
            /* other asserts */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT – КЛАССИКА
                                        PageObject
                          PageObject


      PageObject




                                         ReviewForm
                           ReviewForm


        ReviewForm


                                                      Для тестирования новой страницы
                                                      нужно повторно инициализировать
                                                      компоненты страницы: ReviewForm, ...

     WWW.2GIS.RU


Saturday, 2 January, 13
НОВАЯ СТРУКТУРА
                                         •   Widget – это функциональный блок
                                             страницы
                     SearchWidget        •   Тесты создаются на основе Widget’ов,
                                             а не страниц




                                         •   Повторное использование кода
                                         •   Проще архитектура
          ReviewWidget




     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА”

    public function testAddReviewAndCheckInTheList()
    {
          $this->openReviewPage();
    •    Переходим на страницу отзывов о компании
          $count = $this->review->count();
          $this->review->add($text, $rating, $user);
    •    Смотрим сколько отзывов уже добавлено
          $this->assertEquals($count + 1,
    •    Добавляем тестовый отзыв
                  $this->review->count()
          );
    •    Проверяем что он появился
          /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА”

    public function testAddReviewAndCheckInTheList()
    {
            $this->openReviewPage();
            $count = $this->review->count();
            $this->review->add($text, $rating, $user);
            $this->assertEquals($count + 1,
                          $this->review->count()
            );
            /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
MAPS.2GIS.RU




     WWW.2GIS.RU


Saturday, 2 January, 13
MAPS.2GIS.RU




                          Особенности приложения
        •   Большинство элементов страницы создаются динамически

        •   Картографические элементы создаются при помощи
            картографического API




     WWW.2GIS.RU


Saturday, 2 January, 13
Saturday, 2 January, 13
PAGE OBJECT – КЛАССИКА

    class OnlinePage
    {
        public function __construct($test)
        {
            $this->searchForm = $this->getSearchFormComponent();
            $this->catalog = $this->getCatalogComponent();
            $this->balloon = $this->getBalloonComponent();
            /* ... */
        }

            public function search($what, $where)
            {
                $this->searchForm->fill($what, $where);
                $this->searchForm->submit();
                return $this;
            }
            /* ... */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
PAGE OBJECT – КЛАССИКА

    class OnlinePage
    {
        public function __construct($test)
        {
            $this->searchForm = $this->getSearchFormComponent();
            $this->catalog = $this->getCatalogComponent();
            $this->balloon = $this->getBalloonComponent();
            /* ... */
        }

            public function search($what, $where)
            {
                $this->searchForm->fill($what, $where);
                $this->searchForm->submit();
                return $this;
            }
            /* ... */
    }



     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “СМЕНА ГОРОДА”

    public function testSelectCity()
    {
        $page = $this->getPage();
        $page->citySelect->select('Новосибирск');
            /* ... */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
КОМПОНЕНТЫ

    Page                                   •   Объект Page
                          SearchForm           реализует доступ
     Catalog                                   к компонентам
                                               Catalog, SearchForm
                                               и др.

                                           •   Тест-кейсы
                                               реализуются при
                                               помощи операций
                             Balloon           с объектом Page
                                               и его компонентами




     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ПОЯВЛЕНИЕ BALLOON”

    public function testSelectFirmAndShowBalloon()
    {
          $page = $this->getPage();
    •    Выбираем город
          $page->selectCity('Новосибирск');
          $page->searchForm->send(...);
    •    Выполняем поиск организации (“что” , “где”)
          $firm = $page->catalog->getFirm();
    •    Выбираем случайную фирму из справочника и кликаем по ней
          $firm->click();
          $this->assertNotNull(
    •    Проверяем, что объект balloon отобразился на карте
                             $page->map->getBalloon());
            /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
ПРИМЕР ТЕСТА “ПОЯВЛЕНИЕ BALLOON”

    public function testSelectFirmAndShowBalloon()
    {
            $page = $this->getPage();
            $page->selectCity('Новосибирск');
            $page->searchForm->send(...);
            $firm = $page->catalog->getRandomFirm();
            $firm->click();
            $this->assertNotNull(
                              $page->map->getBalloon());
            /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
КОРОТКАЯ ССЫЛКА



                           http://go.2gis.ru/pis8




Saturday, 2 January, 13
СНИМОК СОСТОЯНИЯ




        •   Состояние – это текущие (runtime) параметры
            всех компонентов страницы
        •   Состояния позволяют проверять корректность работы коротких
            ссылок




Saturday, 2 January, 13
ТЕСТ “КОРОТКАЯ ССЫЛКА”

    public function testShortLink()
    {
        /* ... */
    • Формируем тестовое состояние
        $state = $this->page->createState();
        /*
    • Создаём короткую ссылку and open it
         * Create short link
         */
    • Переходим по короткой ссылке
        $this->assertEquals($state,

    • Сравниваем $this->page->createState());
                 состояния
        /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
ТЕСТ “КОРОТКАЯ ССЫЛКА”

    public function testShortLink()
    {
        /* ... */
        $state = $this->page->createState();
        /*
         * Create short link and open it
         */
        $this->assertEquals($state,
                 $this->page->createState());
        /* other asserts */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
ИНТЕГРАЦИЯ С TMS

    /**
      * Проверка Example feature
      * - step1
      * - step2
      * @suite Example
      * @section Example feature
      */
    public function testExample()
    {
         /* ... */
    }




     WWW.2GIS.RU


Saturday, 2 January, 13
KEEP IT SHORT AND SIMPLE

                2GisOnlineTestFramework       Widget       Test




        Component           Page     Test   FlampTestFramework



     WWW.2GIS.RU


Saturday, 2 January, 13
ЗАКЛЮЧЕНИЕ


    •    Простота в использовании фреймворков позволила подключить к
         автоматизации тестировщиков продуктов

    •    Основной функционал продуктов покрыт автотестами

    •    Простая архитектура фреймворков позволила тестировщикам
         поддерживать и развивать фреймворки




     WWW.2GIS.RU


Saturday, 2 January, 13
СПАСИБО ЗА ВНИМАНИЕ!

                                         Татьяна Курносова
                                            t.kurnosova@2gis.ru
                                               @tanyfromsiberia



      1-2 марта 2013 г., Киев, Украина
Saturday, 2 January, 13

Mais conteúdo relacionado

Destaque

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Особенности автоматизации тестирования: Single-page vs Multi-page (Seleniumcamp 2013)

  • 1. ОСОБЕННОСТИ АВТОМАТИЗАЦИИ ТЕСТИРОВАНИЯ Single-page vs. Multi-page Татьяна Курносова t.kurnosova@2gis.ru 1-2 марта 2013 г., Киев, Украина Saturday, 2 January, 13
  • 2. 2ГИС СЕГОДНЯ • > 200 городов (Новосибирск, Москва, Одесса, Падуя, …) • 4 страны (Россия, Казахстан, Украина, Италия) • > 20 млн. пользователей (desktop, online, mobile) WWW.2GIS.RU Saturday, 2 January, 13
  • 3. ТЕСТИРОВАНИЕ В 2ГИС Quality Assurance 2GIS Online QA Team Developer 2GIS API in Test QA Team Team Flamp QA Team WWW.2GIS.RU Saturday, 2 January, 13
  • 4. ТЕСТИРОВАНИЕ В 2ГИС Quality Assurance 2GIS Online Ручное и автоматизированное QA Team Developer 2GIS API in Test QA Team Team тестирование Flamp QA Team • Разработка фреймворков • Обучение тестировщиков WWW.2GIS.RU Saturday, 2 January, 13
  • 5. ИСТОРИЯ РОЖДЕНИЯ ФРЕЙМВОРКОВ maps.2gis.ru flamp.ru Single-page Multi-page Электронный справочник (карты + справочный контент) Сервис отзывов о компаниях городов России Поставщиком справочных данных является сервис справочного API (api.2gis.ru) WWW.2GIS.RU Saturday, 2 January, 13
  • 6. ИСТОРИЯ РОЖДЕНИЯ ФРЕЙМВОРКОВ maps.2gis.ru flamp.ru Автоматизация тестирования продуктов • Создать фреймворки для автоматизации тестирования двух продуктов (SPA и MPA) • Покрыть базовый функционал автотестами • Single-Page Application (SPA) за минимальное время • Multi-Page Application (MPA) WWW.2GIS.RU Saturday, 2 January, 13
  • 7. ТРЕБОВАНИЯ К ТЕСТОВЫМ ФРЕЙМВОРКАМ • Простая архитектура – лёгкость в освоении для тестировщиков Архитектурный стиль KISS – Keep It Short • Компактные тесты – минимум LOC and Simple • Устойчивость к изменениям, расширяемость WWW.2GIS.RU Saturday, 2 January, 13
  • 8. ИНСТРУМЕНТЫ Tests Framework PHPUnit_Selenium Selenium WWW.2GIS.RU Saturday, 2 January, 13
  • 9. PAGE OBJECT Web Page Page Class Test <html> class { } class { } </html> WWW.2GIS.RU Saturday, 2 January, 13
  • 10. PAGE OBJECT Authentification Page class AuthentificationPage { public function __construct($test) { $this->emailInput = $test->byName('email'); /* ... */ } public function email($value) { $this->emailInput->value($value); return $this; } /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 11. PAGE OBJECT public function testAuthentification() { $this->url('/test_login_page.html'); $page = new AuthentificationPage($this); $homePage = $page->email('test@2gis.ru') ->password('TestPassword') ->submit(); $this->assertEquals('Welcome, Test!', $homePage->welcomeText(); } WWW.2GIS.RU Saturday, 2 January, 13
  • 12. FLAMP.RU WWW.2GIS.RU Saturday, 2 January, 13
  • 13. FLAMP.RU Этапы автоматизации • Базовый функционал продукта • Специализированная сборка, исключающая зависимость от дизайна WWW.2GIS.RU Saturday, 2 January, 13
  • 17. PAGE COMPONENT class ReviewForm() { public function __construct($test) { $this->reviewText = $test->byId('at_text'); $this->reviewRating = $test->byId('at_rating'); $this->reviewSubmit = $test->byId('at_submit'); } public function fill($text, $rating) { $this->reviewText->value($text); $this->reviewRating->value($rating); } public function submit() /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 18. PAGE OBJECT class ReviewPage { public function __construct($test) { $this->authForm = $this->getAuthForm(); $this->reviewForm = $this->getReviewForm(); $this->reviewsList = $this->getReviewsList(); /* ... */ } public function addReview($text, $rating) { $this->reviewForm->fill($text, $rating); $this->reviewForm->submit(); return $this; } /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 19. ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА” public function testAddReviewAndCheckInTheList() { $this->url('...'); $page = new ReviewPage(); $count = $page->getReviewsCount(); $page = $page->addReview($text, $rating); $this->assertEquals( $count + 1, $page->getReviewsCount() ); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 20. ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА” public function testAddReviewAndCheckInTheList() { $this->url('...'); $page = new ReviewPage(); $count = $page->getReviewsCount(); $page = $page->addReview($text, $rating); $this->assertEquals( $count + 1, $page->getReviewsCount() ); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 21. PAGE OBJECT – КЛАССИКА PageObject PageObject PageObject ReviewForm ReviewForm ReviewForm Для тестирования новой страницы нужно повторно инициализировать компоненты страницы: ReviewForm, ... WWW.2GIS.RU Saturday, 2 January, 13
  • 22. НОВАЯ СТРУКТУРА • Widget – это функциональный блок страницы SearchWidget • Тесты создаются на основе Widget’ов, а не страниц • Повторное использование кода • Проще архитектура ReviewWidget WWW.2GIS.RU Saturday, 2 January, 13
  • 23. ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА” public function testAddReviewAndCheckInTheList() { $this->openReviewPage(); • Переходим на страницу отзывов о компании $count = $this->review->count(); $this->review->add($text, $rating, $user); • Смотрим сколько отзывов уже добавлено $this->assertEquals($count + 1, • Добавляем тестовый отзыв $this->review->count() ); • Проверяем что он появился /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 24. ПРИМЕР ТЕСТА “ДОБАВЛЕНИЕ ОТЗЫВА” public function testAddReviewAndCheckInTheList() { $this->openReviewPage(); $count = $this->review->count(); $this->review->add($text, $rating, $user); $this->assertEquals($count + 1, $this->review->count() ); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 25. MAPS.2GIS.RU WWW.2GIS.RU Saturday, 2 January, 13
  • 26. MAPS.2GIS.RU Особенности приложения • Большинство элементов страницы создаются динамически • Картографические элементы создаются при помощи картографического API WWW.2GIS.RU Saturday, 2 January, 13
  • 28. PAGE OBJECT – КЛАССИКА class OnlinePage { public function __construct($test) { $this->searchForm = $this->getSearchFormComponent(); $this->catalog = $this->getCatalogComponent(); $this->balloon = $this->getBalloonComponent(); /* ... */ } public function search($what, $where) { $this->searchForm->fill($what, $where); $this->searchForm->submit(); return $this; } /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 29. PAGE OBJECT – КЛАССИКА class OnlinePage { public function __construct($test) { $this->searchForm = $this->getSearchFormComponent(); $this->catalog = $this->getCatalogComponent(); $this->balloon = $this->getBalloonComponent(); /* ... */ } public function search($what, $where) { $this->searchForm->fill($what, $where); $this->searchForm->submit(); return $this; } /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 30. ПРИМЕР ТЕСТА “СМЕНА ГОРОДА” public function testSelectCity() { $page = $this->getPage(); $page->citySelect->select('Новосибирск'); /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 31. КОМПОНЕНТЫ Page • Объект Page SearchForm реализует доступ Catalog к компонентам Catalog, SearchForm и др. • Тест-кейсы реализуются при помощи операций Balloon с объектом Page и его компонентами WWW.2GIS.RU Saturday, 2 January, 13
  • 32. ПРИМЕР ТЕСТА “ПОЯВЛЕНИЕ BALLOON” public function testSelectFirmAndShowBalloon() { $page = $this->getPage(); • Выбираем город $page->selectCity('Новосибирск'); $page->searchForm->send(...); • Выполняем поиск организации (“что” , “где”) $firm = $page->catalog->getFirm(); • Выбираем случайную фирму из справочника и кликаем по ней $firm->click(); $this->assertNotNull( • Проверяем, что объект balloon отобразился на карте $page->map->getBalloon()); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 33. ПРИМЕР ТЕСТА “ПОЯВЛЕНИЕ BALLOON” public function testSelectFirmAndShowBalloon() { $page = $this->getPage(); $page->selectCity('Новосибирск'); $page->searchForm->send(...); $firm = $page->catalog->getRandomFirm(); $firm->click(); $this->assertNotNull( $page->map->getBalloon()); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 34. КОРОТКАЯ ССЫЛКА http://go.2gis.ru/pis8 Saturday, 2 January, 13
  • 35. СНИМОК СОСТОЯНИЯ • Состояние – это текущие (runtime) параметры всех компонентов страницы • Состояния позволяют проверять корректность работы коротких ссылок Saturday, 2 January, 13
  • 36. ТЕСТ “КОРОТКАЯ ССЫЛКА” public function testShortLink() { /* ... */ • Формируем тестовое состояние $state = $this->page->createState(); /* • Создаём короткую ссылку and open it * Create short link */ • Переходим по короткой ссылке $this->assertEquals($state, • Сравниваем $this->page->createState()); состояния /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 37. ТЕСТ “КОРОТКАЯ ССЫЛКА” public function testShortLink() { /* ... */ $state = $this->page->createState(); /* * Create short link and open it */ $this->assertEquals($state, $this->page->createState()); /* other asserts */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 38. ИНТЕГРАЦИЯ С TMS /** * Проверка Example feature * - step1 * - step2 * @suite Example * @section Example feature */ public function testExample() { /* ... */ } WWW.2GIS.RU Saturday, 2 January, 13
  • 39. KEEP IT SHORT AND SIMPLE 2GisOnlineTestFramework Widget Test Component Page Test FlampTestFramework WWW.2GIS.RU Saturday, 2 January, 13
  • 40. ЗАКЛЮЧЕНИЕ • Простота в использовании фреймворков позволила подключить к автоматизации тестировщиков продуктов • Основной функционал продуктов покрыт автотестами • Простая архитектура фреймворков позволила тестировщикам поддерживать и развивать фреймворки WWW.2GIS.RU Saturday, 2 January, 13
  • 41. СПАСИБО ЗА ВНИМАНИЕ! Татьяна Курносова t.kurnosova@2gis.ru @tanyfromsiberia 1-2 марта 2013 г., Киев, Украина Saturday, 2 January, 13