[JAVA] ATDD development on iOS (basic)

It is a continuation of the following.

System architecture

As mentioned above, it is reprinted. _Cucumber Workflow (1).jpg

Project structure

├─ src
   ├─ test
      ├─ java
      |  └─ jp.co.hoge.Project.E2ETest
      |     ├─ pageobject
      |     └─ steps
      |     └─ utils
      └─ resources
         └─ jp.co.hoge.Project.E2ETest
            └─ feature files

PageObject A PageObject is an object that represents the relationship between a page and a user (regardless of the test). The following conditions are met.

PageObject sample

PageObject basically means something that meets the above requirements, but due to development reasons, we did not make it completely compliant. For example, this time we have prepared a PageObject called BasePage as the base class of PageObject. Basically, this class is inherited when creating a new PageObject. This BasePage implements a public method for checking the existence of elements. Although the method in the above principle is contrary to returning PageObjects, I decided to implement the check for existence on each PageObject for convenience.

///PageObject Example
public class SearchPage extends BasePage {
    public SearchPage(IOSDriver driver) {
        super(driver);
    }

    @iOSXCUITFindBy(xpath = "//*[@name=\"Search\"]")
    private IOSElement navigationBar;

    @iOSXCUITFindBy(xpath = "//*[@name=\"Find an artist\"]")
    private IOSElement textSearchField;

    @iOSXCUITFindBy(accessibility = "Ranking")
    private IOSElement ranking;

    ...

    public SearchResultPage searchText(String keyword) {
        textSearchField.setValue(keyword);
        driver.hideKeyboard();
        return new SearchResultPage(driver);
    }

    public SearchSuggestPage showSuggest(String keyword) {
        textSearchField.setValue(keyword);
        return new SearchSuggestPage(driver);
    }

    public Boolean existsNavigationBar() {
        return checkVisibilityOfElement(navigationBar);
    }

    ...

Feature The scenario is written in plain text. Here comes a syntax rule called Gherkin. Sample

Feature:Display the page to search for

  Scenario:Press the Find tab
Launch the Given app and move to the search screen
Then on the search screen, "Search" is displayed in the header.

Steps Keyword You can use the keywords ** Given **, ** When **, ** Then **, ** And ** or ** But ** for each step. However, these are not taken into account when looking for step definitions.

Steps Argument You can pass arguments to the step definition. However, there are restrictions on the types that can be used. https://cucumber.io/docs/cucumber/cucumber-expressions/#parameter-types

// example feature
Scenario:Display the control panel when playing music
Tap the Given Search tab
And from text search"Kenshi YONEZU"Enter
    ...
// example steps definision
@Given("From text search{string}Enter")
public void Display Kenshi Yonezu from text search(String keyword) {
    searchResultPage = searchPage.searchText(keyword);
}

Skip Test If there is a feature that you do not want to execute the test on CI, such as a step in the middle of development, you can skip the execution of the test by adding the ignore annotation.

@ignore
Feature:Advertising display

Recommended Posts

ATDD development on iOS (basic)
iOS app development: Timer app (2. Timer display)
ROS app development on Android
[IOS] canOpenURL becomes false on iOS14
Ruby on Rails basic learning ①
iOS app development: Timer app (summary)
Ruby on Rails Basic Memorandum
Tracking Authorization Status memo on iOS 14
Basic knowledge of Ruby on Rails
[Swift] Acquisition of IDFA on iOS14
Complete self-study IOS app development diary
iOS App Development Skill Roadmap (Introduction)
Using a local network on iOS 14
iOS app development: Timer app (4. Countdown implementation)
iOS app development: Timer app (1. Timer time setting)
Build Unity development environment on docker
iOS app development: Timer app (10. Create animation)
Install Java development environment on Mac