Shiratesを使ってみよう - testrunファイル -
前回の記事ではShiratesの環境構築と簡単なテストコードの作成を説明しました。 wave-diary.hatenablog.com
本記事で説明する内容を手元で実行する場合は先に前回の記事に従ってプロジェクトを作成してください。 または完成したプロジェクトをこちらから入手してください。
Shiratesのパラメーター設定
Shiratesは パラメーター構成ファイル で起動パラメーターを設定できます。
testrun.propertiesファイル
testrun.propertiesファイルを編集して以下の内容に書き換えます。
#testrun ## OS -------------------- #os=ios ## Config -------------------- ## [Android] android.configFile=testConfig/settingsConfig.json android.profile=Android 12 ## [iOS] #ios.configFile= #ios.profile= ## Stub -------------------- #stubServerUrl=http://stub1 ## Test mode -------------------- #noLoadRun=true ## Priority filter -------------------- #must=false #should=false #want=false #none=false ## Log -------------------- logLanguage=ja #enableSyncLog=false #enableTestList=false #enableSpecReport=false #enableInnerMacroLog=true #enableInnerCommandLog=true #enableSilentLog=true #enableTapElementImageLog=true #enableXmlSourceDump=false #enableRetryLog=false #enableTrace=true #enableShellExecLog=true #enableTimeMeasureLog=true #enableImageMatchDebugLog=true #testResults= #testListDir= ## Screenshot -------------------- #screenshotScale=0.333333 #autoScreenshot=false #onChangedOnly=false #onCondition=false #onAction=false #onExpectation=false #onExecOperateCommand=false #onCheckCommand=false #onScrolling=false #manualScreenshot=false ## Image Matching -------------------- #imageMatchingScale= #imageMatchingThreshold= #imageMatchingCandidateCount= ## Appium -------------------- appiumServerUrl=http://127.0.0.1:4720/ appiumPath=appium appiumArgs=--session-override --relaxed-security #appiumArgsSeparator= #appiumServerStartupTimeoutSeconds= #appiumSessionStartupTimeoutSeconds= #implicitlyWaitSeconds= #appPackageFile= #appPackageDir= #packageOrBundleId= #startupPackageOrBundleId= #startupActivity= ## TestDriver -------------------- #resuseDriver= #retryMaxCount= #retryTimeoutSeconds= #retryIntervalSeconds= ## App operation -------------------- #appIconName= #tapAppIconMethod= #tapAppIconMacro= #shortWaitSeconds= #waitSecondsForAnimationComplete= #waitSecondsOnIsScreen= #waitSecondsForConnectionEnabled= #swipeDurationSeconds= #flickDurationSeconds= #swipeMarginRatio= #scrollVerticalMarginRatio= #scrollHorizontalMarginRatio= #tapHoldSeconds= #syncWaitSeconds= ## Custom -------------------- #CustomObject.scan.dir=src/test/kotlin ## Macro -------------------- #MacroObject.scan.dir=src/test/kotlin ## Spec-Report -------------------- #specReport.replace.MANUAL= #specReport.replace.MANUAL.reason= #specReport.replace.SKIP= #specReport.replace.SKIP.reason= ## misc #android.swipeOffsetY=-20 #ios.swipeOffsetY=-5 #xmlSourceRemovePattern= #boundsToRectRatio= #ios.selectIgnoreTypes=XCUIElementTypeCell,XCUIElementTypeApplication #android.titleSelector=<#action_bar||#toolbar||#app_bar>:descendant(${title}||@${title}) #ios.titleSelector=<.XCUIElementTypeNavigationBar>:descendant(.XCUIElementTypeStaticText&&${title}) #android.webTitleSelector=.android.webkit.WebView&&${webTitle} #ios.webTitleSelector=<.XCUIElementTypeWebView>:descendant(${webTitle}&&visible=false) #jquerySource=
多くのパラメーターは#でコメントアウトされています。必要になった場合は#を削除して設定を有効化します。 パラメーターの詳細についてはParametersを参照してください。
使用頻度の高いパラメーターのセクションを以下に紹介します。
Test Modeセクション
通常モードと無負荷実行モードの切り替えを行うことができます。
## Test mode -------------------- #noLoadRun=true
コメントを解除して
noLoadRun=true
を指定すると無負荷実行モードになります。無負荷実行モードでは実際のテスト実行を行わずテスト仕様書(Spec-Report)のみを出力します。
Logセクション
ログに関する設定を行うことができます。
## Log -------------------- logLanguage=ja #enableSyncLog=false #enableTestList=false #enableSpecReport=false #enableInnerMacroLog=true #enableInnerCommandLog=true #enableSilentLog=true #enableTapElementImageLog=true #enableXmlSourceDump=false #enableRetryLog=false #enableTrace=true #enableShellExecLog=true #enableTimeMeasureLog=true #enableImageMatchDebugLog=true #testResults= #testListDir=
logLanguage
ログの言語です。デフォルトは英語です。日本語に設定する場合は
logLanguage=ja
を指定します。
testResults
ログの出力ディレクトリを変更する場合は書き換えます。デフォルトはダウンロードディレクトリ下のTestResults
フォルダです。
Appiumセクション
Appiumに関する設定を行うことができます。(Appiumのより詳細な設定はtestConfigファイルで行います。)
## Appium -------------------- appiumServerUrl=http://127.0.0.1:4720/ appiumPath=appium appiumArgs=--session-override --relaxed-security #appiumArgsSeparator= #appiumServerStartupTimeoutSeconds= #appiumSessionStartupTimeoutSeconds= #implicitlyWaitSeconds= #appPackageFile= #appPackageDir= #packageOrBundleId= #startupPackageOrBundleId= #startupActivity=
appiumServerUrl
Appiumで使用するURLを変更したい場合は書き換えます。たとえばポート番号を4721に変更したい場合は以下のように書き換えます。
appiumServerUrl=http://127.0.0.1:4721/
appiumArgs
Appiumの起動オプションを変更したい場合は書き換えます。
日本語モードでのテストの実行
日本語に設定した状態で前回の記事で作成したプログラムを実行すると以下のように出力されます。
比較のために英語モードでの出力を以下に記載します。
これらの出力は単一のテストコードから出力しています。
このようにShiratesは日本語による可読性の高いログの出力をサポートしています。