PerfectoとXCUITest

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Perfectoのデバイス上でiOSアプリのアクセシビリティ問題をテストします。

Not for use with personal data

PerfectoでUIテストを実行し、デバイス間のアプリのアクセシビリティ状態を包括的に理解しましょう。

必要要件:

  • Perfecto Enterprise Private Cloud

前提条件

  1. UIテストはiOS用axe DevTools Mobileと統合されています。必要に応じて、 クイックスタートガイド をご覧ください。
  2. アプリを配布用に準備します。本物のデバイス上でPerfectoでテストを行うため、アプリとUIテストターゲットを設定することでプロセスがスムーズになります。
  3. インストール Gradle

サンプルプロジェクト

例を探していますか?当社のサンプルiOSプロジェクトはテストのための統合が準備されています。

  1. 前提条件を確認してください。

  2. 以下からサンプルプロジェクトをダウンロードします: Githubのサンプルプロジェクト

  3. 開発チームをアプリとUITestターゲットに追加するために、Xcodeプロジェクトファイルを開きます

  4. モバイル用axe DevToolsのAPIキーを追加します リンクテキスト 以下に追加します。 Login.swift

  5. 次の場所の値をあなたのPerfectoクラウドに合わせて調整します:

    • perfecto.sh
    CLOUDNAME="<<perfecto-cloud-name>>"
    • configFile.json - 値を確認 cloudURLsecurityToken、および deviceName
    {
      "cloudURL": "<<perfecto-cloud-name>>",
      "securityToken": "<<security-token>>",
      ...
      "devices": [
        {
          "deviceName": "00005302-BF389EDED8B22DBD"
        }
      ],
      ...
    }
  6. ターミナルウィンドウを開き、「 cd 」、その後、「 axe-devtools-ios-sample-app 」をFinderからターミナルウィンドウにドラッグ&ドロップします。Enterキーを押します。

  7. 同じウィンドウで「 sh perfecto.sh」と入力します。Enterキーを押します。

サンプルプロジェクトにはPerfectoの統合に使用される3つのファイルがあります: perfecto.shconfigFile.json、および build.gradle

PerfectoをXCUIテストに追加する

セットアップ

注: すべての3つのファイルはプロジェクトのルートに配置されていることを期待しています。

  1. テストをPerfectoのプラットフォームで実行するためにシェルスクリプトを作成します。以下の値をお使いのアプリケーションとPerfectoクラウドに合わせて調整してください: APP_LOCATIONAPP_NAME 、および CLOUDNAME

    APP_LOCATION="DerivedData/Build/Products/Debug-iphoneos"
    APP_NAME="axe-devtools-ios-sample-app"
    CLOUDNAME="<<perfecto-cloud-name>>"
    
    TOKEN="<<security-token>>"
    JOBNUMBER="<<job-number>>"
    
    rm -rf *.app
    # Prepare app files
    gradle buildForRealDevice
    mv $APP_LOCATION/$APP_NAME.app .
    mv $APP_LOCATION/"$APP_NAME"UITests-Runner.app .
    # Run on Perfecto cloud
    gradle perfecto-xctest -PconfigFileLocation=configFile.json -PcloudURL=$CLOUDNAME.perfectomobile.com -PsecurityToken=$TOKEN -PjobNumber=$JOBNUMBER --stacktrace --debug
    rm -rf DerivedData
  2. Gradleファイルを追加し、 build.gradle。最後のセクションをお使いのアプリケーションの値に更新してください。

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            def flatDirPath = project.hasProperty('flatDirPath') ? project.getProperty('flatDirPath') : ''
            if(flatDirPath != '') {
                flatDir {
                    dirs flatDirPath
                }
            } else {
                maven {
                    url "https://repo1.perfectomobile.com/public/repositories/maven/"
                }
            }
        }
    
        dependencies {
            classpath "com.perfectomobile.instrumentedtest.gradleplugin:plugin:+"
        }
    }
    
    apply plugin: 'com.perfectomobile.instrumentedtest.gradleplugin'
    
    perfectoGradleSettings {
        configFileLocation "configFile.json"
    }
    
    tasks.register('cleanPreviousBuild', Exec) {
        workingDir projectDir
        commandLine "bash", "-c", "rm -fr *.xctestproducts dd"
    }
    
    tasks.register('buildForRealDevice') {
        dependsOn cleanPreviousBuild
        doLast {
            exec {
                commandLine "bash", "-c", "xcodebuild build-for-testing " +
                        " -destination generic/platform='iOS' " +
                        " -configuration Debug" +
                        " -scheme axe-devtools-ios-sample-app" +
                        " -target axe-devtools-ios-sample-appUITests" + 
                        " -sdk iphoneos" + 
                        " -derivedDataPath DerivedData/  -quiet -allowProvisioningUpdates" 
            }
        }
    }
  3. Perfectoの設定JSONを追加し、値を確認 cloudURLsecurityTokenappPathtestAppPath および deviceName あなたのPerfecto認証、アプリケーション、および利用可能な実デバイスUUIDに合わせてください。

    上記の build.gradle は、 configFile.json という名前の設定ファイルを探しています。異なる名前を使用する場合は必ず更新してください。

    {
      "cloudURL": "<<perfecto-cloud-name>>",
      "securityToken": "<<security-token>>",
      "appPath": "axe-devtools-ios-sample-app.app",
      "testAppPath": "axe-devtools-ios-sample-appUITests-Runner.app",
      "devices": [
        {
          "deviceName": "00005302-BF389EDED8B22DBD"
        }
      ],
      "tags": [
        "xcuitest",
        "sample"
      ],
      "projectName": "Axe-XCUITest",
      "projectVersion": "v1-test",
      "jobName": "AXE-XCUITEST-LATEST",
      "jobNumber": 1,
      "branch": "master",
      "failBuildOnFailure": false,
      "installationDetails": {
        "preCleanUp": true,
        "resign": true
      },
      "postExecution": {
        "uninstall": false
      },
      "acquireDeviceRetryNumber": 1,
      "acquireDeviceRetryInterval": 200,
      "debug": true,
      "runUnitTests": true,
      "runUiTests": true,
      "shard": false,
      "takeScreenshotOnTestEnd": true,
      "testTimeout": "60000"
    }

実行

プロジェクトをセットアップしたら、シェルスクリプトを実行してPerfectoクラウドでテストを実行します。

ローカルで確認:

  1. ターミナルでプロジェクトを開きます。
  2. 入力して sh perfecto.sh 、Enterキーを押します。
  3. Perfecto Cloudのテスト分析を開き、最新のレポートを確認してください。

役立つリンク: