Giter Site home page Giter Site logo

vinipx / ios-test-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from suparna-khamaru/ios-test-app

0.0 0.0 0.0 276 KB

iOS app for testing using XCUITest Framework in Swift language

License: Apache License 2.0

JavaScript 3.86% Objective-C 67.49% Swift 28.64%

ios-test-app's Introduction

Welcome to "XCUITest - UI Test Framework in Swift"

The UI Test Automation Framework used in this sample project has the following prime compositions:

1. BaseClass

  • extends XCTestCase class of XCTest framework
  • serves as the universal Base Class to the entire UI Test framework
  • All tests in the UI Test project shall follow the commands mentioned in BaseClass
  • Invokes the following methods:
    • setUp()
    • tearDown()

2. TestClass

  • extends the above mentioned BaseClass
  • consists of tests

Each test follow Fluent Page Object Model design Pattern:

 func testCalculateSum() {
    let calculateScreen = CalculateScreen(app)
    
    calculateScreen
        .enter(number: two, in: calculateScreen.firstTextField)
        .enter(number: five, in: calculateScreen.secondTextField)
        .tapOn(button: calculateScreen.computeButton)
    
    XCTAssertEqual(seven, calculateScreen.actual)
 }

3. TestData enum

  • Test Data management is essential in any test framework

  • Agenda is to have all the test data in one place for better reuse

    enum TestData {
       static let one = 1
    } 
    

4. UniqueId enum

  • Accessibility Identifiers

  • Intention is to use the same accessibility identifiers in dev code and test code for all the elements

     enum UniqueId {
        static let computeButton = "ComputeSumButton"
     }
    

5. LandingPageElements class

  • lists down all the elements in one place to avoid test code duplication & thus improves better reusability.

    lazy var computeButton = app.buttons[UniqueId.computeButton].firstMatch

    lazy var actual = Int(app.staticTexts[UniqueId.answerLabel].firstMatch.label)

6. UIStatus enum

  • Wait for different kind of actions

7. CalculateScreen class

  • basis of page objects
  • consists of optimised test code
  • concentrates on reusability
  • helps in achieving fluent interface

Non Optimised:

func calculateSum(firstNumber: Int, secondNumber: Int) {
    firstTextField.tap()
    firstTextField.typeText(String(firstNumber))
    secondTextField.tap()
    secondTextField.typeText(String(secondNumber))
    computeButton.tap()
}

Optimised: Recommended way

func enter(number: Int, in field: XCUIElement) -> Self {
    field.tap()
    field.typeText(String(number))
    return self
}

func tapOn(button: XCUIElement) {
    expect(element: button, status: .hittable, withIn: 20)
    button.tap()
}

ios-test-app's People

Contributors

imurchie avatar sebv avatar jlipps avatar jonahss avatar suparna-khamaru avatar scottdixon avatar greenkeeper[bot] avatar sa-spag avatar dpgraham avatar mhan83 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.