Автоматизация тестирования
     сложных систем:
 mixed mode automated test
           case.
       Виктор Короневич
Content

1.   Структура mixed-mode теста
2.   Особенности реализации решения
3.   Пример mixed-mode теста
4.   Demo
Структура mixed-mode теста

Тест:
- pre-test actions;
- preconditions;
- set up fixture;
- steps;
- check;
- post-test actions;
Особенности реализации решения
Modes:
- db testing (create/clean-up scripts – mysql driver);
   link: http://www.mysql.com/products/connector/

-    web services testing (create/load scripts – apache httpclient
     wrapper);
     link: http://hc.apache.org/httpclient-3.x/

-    web testing (functional scripts – Selenium 2.x Web Driver);
     link: http://seleniumhq.org/docs/03_webdriver.jsp#

-    iOS testing (functional scripts – Frank project);
     link: https://github.com/moredip/Frank
Пример
@TestFixture(username = test_user, password = test_pass)
@CleanUp(script = "./scripts/clean_up_db_users.sql")
@Test(timeout = min_timeout)
public void testUserBuyPaidExercise(){
             // [STEPS]
             // scenario: 1.login -> 2.tap buy items -> 3.gather expected data ->
             //          4.buy the first item -> 5.go to my items -> 6.gather actual data

             // step 1-2
             BuyItemsScreen buyItemsScreen =
             ScreenFactory.getInstance().getLoginScreen().login(username, password).tapBuyItems();

             // step 3
             Exercise expectedExercise = buyItemsScreen.getFirstItem();
             int moneyCount            = buyItemsScreen.getMoneyCount();
             int expectedItemsCount = 1;
             int expectedMoneyCount = moneyCount -
                         CurrencyExchange.convertToBYR(expectedExercise.getPrice(), Currency.USD);
Пример
@TestFixture(username = test_user, password = test_pass)
@CleanUp(script = "./scripts/clean_up_db_users.sql")
@Test(timeout = min_timeout)
public void testUserBuyPaidExercise(){
             // [STEPS]
             // scenario: 1.login -> 2.tap buy items -> 3.gather expected data ->
             //      4.buy the first item -> 5.go to my items -> 6.gather actual data

             …

           // step 4-5
           MyItemsScreen myItemsScreen =
buyItemsScreen.tapFirstItem().tapBuyButton().tapMyItems();

             // step 6
             int actualItemsCount = myItemsScreen.getItemsCount();
             Exercise actualExercise = myItemsScreen.getFirstItem();
             int actualMoneyCount = myItemsScreen.getMoneyCount();

}
Пример
@TestFixture(username = test_user, password = test_pass)
@CleanUp(script = "./scripts/clean_up_db_users.sql")
@Test(timeout = min_timeout)
public void testUserBuyPaidExercise(){
             // [STEPS]
             // scenario: 1.login -> 2.tap buy items -> 3.gather expected data ->
             //      4.buy the first item -> 5.go to my items -> 6.gather actual data

             …

             // [CHECK]
             // #1: exercises count should be 1 (we buy only 1 item)
             Assert.assertEquals(expectedItemsCount, actualItemsCount);
             // #2: exercise name and price should be equal
             CustomAssert.assertEquals(expectedExercise, actualExercise);
             // #3: money count should be reduced on expected exercise price including the current
             valid currency course
             Assert.assertEquals(expectedMoneyCount, actualMoneyCount);
}
Пример
public class IntegrationTestSet extends TestSetTexture{

            @BeforeClass
            public static void setUpAllTests(){
                          install_iPhoneApp();
            }
            @Before
            public void setUpTest(){
                          sharedTCFixture();
            }
            @After
            public void tearDownTest(){
                          ScreenFactory.getInstance().getMyItemsScreen().logout();
            }
            @AfterClass
            public static void tearDownAllTests(){
                          quit_iPhoneApp();
            }
            …
Пример
public class TestSetTexture extends JUnitExtension{
              protected final static String test_user = "test_user";
              protected final static String test_pass = "test_pass";
              …
              protected static void install_iPhoneApp(){
                           SUT.start();
              }

             protected static void quit_iPhoneApp(){
                         SUT.quit();
             }

             protected void sharedTCFixture(){
                         int eCount = 100;

                          SUT.registerUser(test_user, test_pass);
                          SUT.createExercises(eCount);
             }
}
Demo
Вопросы
Feedback

Виктор Короневич
Senior Software Test Automation Engineer

Contacts:
- LinkedIn at www.linkedin.com/in/agileseph
- Email at koronevichw@tut.by
- Skype at viktar_karanevich

Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated test case, Короневич Виктор

  • 1.
    Автоматизация тестирования сложных систем: mixed mode automated test case. Виктор Короневич
  • 2.
    Content 1. Структура mixed-mode теста 2. Особенности реализации решения 3. Пример mixed-mode теста 4. Demo
  • 3.
    Структура mixed-mode теста Тест: -pre-test actions; - preconditions; - set up fixture; - steps; - check; - post-test actions;
  • 4.
    Особенности реализации решения Modes: -db testing (create/clean-up scripts – mysql driver); link: http://www.mysql.com/products/connector/ - web services testing (create/load scripts – apache httpclient wrapper); link: http://hc.apache.org/httpclient-3.x/ - web testing (functional scripts – Selenium 2.x Web Driver); link: http://seleniumhq.org/docs/03_webdriver.jsp# - iOS testing (functional scripts – Frank project); link: https://github.com/moredip/Frank
  • 5.
    Пример @TestFixture(username = test_user,password = test_pass) @CleanUp(script = "./scripts/clean_up_db_users.sql") @Test(timeout = min_timeout) public void testUserBuyPaidExercise(){ // [STEPS] // scenario: 1.login -> 2.tap buy items -> 3.gather expected data -> // 4.buy the first item -> 5.go to my items -> 6.gather actual data // step 1-2 BuyItemsScreen buyItemsScreen = ScreenFactory.getInstance().getLoginScreen().login(username, password).tapBuyItems(); // step 3 Exercise expectedExercise = buyItemsScreen.getFirstItem(); int moneyCount = buyItemsScreen.getMoneyCount(); int expectedItemsCount = 1; int expectedMoneyCount = moneyCount - CurrencyExchange.convertToBYR(expectedExercise.getPrice(), Currency.USD);
  • 6.
    Пример @TestFixture(username = test_user,password = test_pass) @CleanUp(script = "./scripts/clean_up_db_users.sql") @Test(timeout = min_timeout) public void testUserBuyPaidExercise(){ // [STEPS] // scenario: 1.login -> 2.tap buy items -> 3.gather expected data -> // 4.buy the first item -> 5.go to my items -> 6.gather actual data … // step 4-5 MyItemsScreen myItemsScreen = buyItemsScreen.tapFirstItem().tapBuyButton().tapMyItems(); // step 6 int actualItemsCount = myItemsScreen.getItemsCount(); Exercise actualExercise = myItemsScreen.getFirstItem(); int actualMoneyCount = myItemsScreen.getMoneyCount(); }
  • 7.
    Пример @TestFixture(username = test_user,password = test_pass) @CleanUp(script = "./scripts/clean_up_db_users.sql") @Test(timeout = min_timeout) public void testUserBuyPaidExercise(){ // [STEPS] // scenario: 1.login -> 2.tap buy items -> 3.gather expected data -> // 4.buy the first item -> 5.go to my items -> 6.gather actual data … // [CHECK] // #1: exercises count should be 1 (we buy only 1 item) Assert.assertEquals(expectedItemsCount, actualItemsCount); // #2: exercise name and price should be equal CustomAssert.assertEquals(expectedExercise, actualExercise); // #3: money count should be reduced on expected exercise price including the current valid currency course Assert.assertEquals(expectedMoneyCount, actualMoneyCount); }
  • 8.
    Пример public class IntegrationTestSetextends TestSetTexture{ @BeforeClass public static void setUpAllTests(){ install_iPhoneApp(); } @Before public void setUpTest(){ sharedTCFixture(); } @After public void tearDownTest(){ ScreenFactory.getInstance().getMyItemsScreen().logout(); } @AfterClass public static void tearDownAllTests(){ quit_iPhoneApp(); } …
  • 9.
    Пример public class TestSetTextureextends JUnitExtension{ protected final static String test_user = "test_user"; protected final static String test_pass = "test_pass"; … protected static void install_iPhoneApp(){ SUT.start(); } protected static void quit_iPhoneApp(){ SUT.quit(); } protected void sharedTCFixture(){ int eCount = 100; SUT.registerUser(test_user, test_pass); SUT.createExercises(eCount); } }
  • 10.
  • 11.
  • 12.
    Feedback Виктор Короневич Senior SoftwareTest Automation Engineer Contacts: - LinkedIn at www.linkedin.com/in/agileseph - Email at koronevichw@tut.by - Skype at viktar_karanevich