メインコンテンツまでスキップ

自動テスト出力を解釈する

Last updated on May 22, 2024

概要

自動テストは、通常、自動化されたビルドパイプラインの一部であり、頻繁にビルドする状況でのコストを削減するために使用します。

自動テストでは、2 種類の出力が生成されます。

  1. Unreal ログ:このログは、コマンドラインで実行するとコマンドラインに表示され、Unreal Editor で実行すると Unreal ログウィンドウに表示されます。Unreal ログファイルとはつまり、セッション中に Unreal コンソールに送られる出力です。デフォルトでは、ログは以下に保存されます
\<ProjectRoot>\ProjectName\Saved\Logs
  1. BlackBox ログファイル:テストでは、n 個の BlackBox ログファイルが生成されます。各ファイルには、JSON 行形式で、あるレベルでのテスト結果が含まれています。BlackBox ログファイルのレイアウトは次のとおりです。
<header>
---
<body>
---
<footer>

Unreal を使用して自動テストを 1 回実行するたびに、BlackBox ログファイルが生成されます。以下のように、パスは任意の場所となり、後で BlackBox CLI でファイルをアップロードする際に使用します。

\<ProjectRoot>\ProjectName\Saved\Logs\AutomatedTest\AutomatedTest_Windows_Level1.json

BlackBox ログファイル

BlackBox ログファイルヘッダー

BlackBox ログファイルの <header> 部分は次のようになります。

{
"@encoding": "blackbox/snifftest+json.v2.0.0"
}

"@encoding" は、この BlackBox ログファイルのエンコーディングバージョンです。エンコーディング値が最新であることを確認します。このエンコーディングは、BlackBox Hub にこのファイルの形式を伝えます。

BlackBox ログファイル本文

テスト結果の <body> 部分は、次の形式になります。

{"type": "begin_test", "name": "test1"}
{"type": "msg", "msg_type": "error", "msg": "errors", "callstack":"C:\Dev\Project\Source\Project\Private\Automation\AutoCommands.cpp (777)"}
{"type": "msg", "msg_type": "warning", "msg": "warning", "callstack":"C:\Dev\Project\Source\Project\Private\Automation\AutoCommands.cpp (778)"}
{"type": "msg", "msg_type": "info", "msg": "info", "callstack":"C:\Dev\Project\Source\Project\Private\Automation\AutoCommands.cpp (779)"}
{"type": "end_test", "name": "test1", "result": "success"}

例:

{"type":"begin_test","name":"Mantle"}
{"type":"msg","msg_type":"info","msg":"MantleFromActorsPosition test : start","callstack":"C:\Dev\Project\Source\Project\Private\Automation\AutoCommands_Locomotion.cpp (777)"}
{"type":"msg","msg_type":"info","msg":"MantleFromActorsPosition Teleport to Mantle1","callstack":""C:\Dev\Project\Source\Project\Private\Automation\AutoCommands_Locomotion.cpp (830)"}
{"type":"msg","msg_type":"info","msg":"MantleFromActorsPosition test : Mantle state reached","callstack":""C:\Dev\Project\Source\Project\Private\Automation\AutoCommands_Locomotion.cpp (877)"}
{"type":"msg","msg_type":"info","msg":"MantleFromActorsPosition from actor (Mantle1) : Mantle Success","callstack":""C:\Dev\Project\Source\Project\Private\Automation\AutoCommands_Locomotion.cpp (884)"}
{"type":"msg","msg_type":"info","msg":"MantleFromActorsPosition test : finish","callstack":""C:\Dev\Project\Source\Project\Private\Automation\AutoCommands_Locomotion.cpp (892)"}
{"type":"end_test","name":"Mantle","result":"success"}

ログは "begin_test""end_test" の内部にラップされます。テスト内にエラータイプのログがある場合、テストは不合格と見なされます。

"begin_test" タイプの本文は、次のパラメータで構成されています。

  • 現在の JSON 行の type (タイプ)"type":"begin_test" の形式
  • 現在のテストの name (名前)"name": "test1" の形式

"msg" タイプの本文は、次のパラメータで構成されています。

  • 現在の JSON 行の type (タイプ)"type":"msg" の形式
  • msg_type は、ログの冗長性タイプ (info、error、warning)
  • msg はログメッセージ
  • callstack は、ログの呼び出し元となるコールスタック

"end_test" タイプの本文は、次のパラメータで構成されます。

  • 現在の JSON 行の type (タイプ)"type":"end_test" の形式
  • 現在のテストの name (名前)
  • 現在のテストの result (結果)(エラーログメッセージがある場合、"failed" になる)

BlackBox ログファイルフッター

テスト結果の <footer> 部分は次のようになります。

{
test_id : "", map: "", total_test : "", failed : "", success : "", result : ""
}
  • test_id は生成されたランダムな UUID
  • map は、現在のテストが実行されているマップ (レベル)
  • total_test は、このテストで実行された総アクション数 (または <body> 部分の総行数)
  • failed は、不合格のテストの数
  • success は、合格したテストの数
  • result は、現在のマップ (レベル) でのテストの結果(success または failed。結果は、本文内のレコードのいずれにも失敗した結果がない場合にのみ success となる)

テスト結果の例

ABShooter というゲームを使用したレベル 1 の BlackBox ログファイルの例:

{
"@encoding": "blackbox/snifftest+json.v1.0.1"
}
---
{"type":"begin_test","name":"LoadMap-Level_1"}
{"type":"msg","msg_type":"warning","msg":"RegisterLocationMarkersForBodyPartCaps has been called", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"warning","msg":"GetVertexLocations returned false for mesh HeadStump.", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"info","msg":"FlushAsyncLoading: 1 QueuedPackages, 0 AsyncPackages", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"info","msg":"ULevelStreaming::RequestLevel(/Game/Maps/Game/Escape/Sections/Security/Escape_Security_VFX) is flushing async loading", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"error","msg":"USoundControllerComponent::BeginPlay - sound slots not configured!", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"error","msg":"USoundControllerComponent::BeginPlay - sound slots not configured!", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"end_test","name":"LoadMap-Level_1","result":"failed"}
{"type":"begin_test","name":"Flashlight-PlayerStart"}
{"type":"msg","msg_type":"info","msg":"Flashlight test : start", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"msg","msg_type":"info","msg":"Flashlight test : Success", "callstack":""C:\Dev\Project\Source\Project\Private\Automation\Something.cpp (830)"}
{"type":"end_test","name":"Flashlight-PlayerStart","result":"success"}
---
{
test_id : "fc341e58-9a5a-48e6-9ffc-c3b398f935e5", map: "Level_1", total_test : "2", failed : "1", success : "1", result : "failed"
}