GGua 日本語リファレンスEnglishGitHub ↗
英語版が正式な参照です。内容に差異がある場合は、英語版を優先してください。
DOCS / .NET PACKAGES

.NETパッケージ

CoreとTestingを共通基盤に、共有Runtime、Godot/Unityホスト、PNG比較、Semantic操作のRecordingを必要な場所だけへ追加します。

インストール

必要なパッケージだけ追加powershell
dotnet add package Gua.Core
dotnet add package Gua.Testing

# engine adapterを実装する場合
dotnet add package Gua.Runtime

# engine processを外部起動するテスト
dotnet add package Gua.Testing.Godot
dotnet add package Gua.Testing.Unity

# 必要な機能だけオプトイン
dotnet add package Gua.Testing.Visual
dotnet add package Gua.Testing.Recording

--versionを省略すると、.NET CLIがNuGetで公開されている最新の安定版を解決します。再現可能なbuildにするため、更新されたproject fileまたはcentral package fileをcommitし、Guaパッケージは同じバージョン系列へ揃えてください。VisualRecordingは独立しており、通常のSemantic UIテストへPNG codecや記録機能を持ち込みません。

NuGet: Core · Testing · Testing.Godot · Testing.Unity · Runtime · Testing.Visual · Testing.Recording

どのパッケージを選ぶか

やりたいこと追加するパッケージ使う場面
通常のSemantic UIテストGua.Testing + engine host表示、活性状態、text、value、操作後の状態遷移を検証。
独自engine adapterを作るGua.Runtimeゲーム側でSemantic frame、action、screenshot、Inspector bridgeを実装。
見た目のregressionを検出Gua.Testing.Visualclipping、位置ずれ、asset・theme違い、予期しないoverlayを検出。
操作scenarioを保存・再生Gua.Testing.Recording回帰flow、bug再現、長いユーザー導線をSemantic targetで共有。

Target Framework

パッケージnet10.0netstandard2.1主な用途
Gua.CoreネイティブGuaのC ABIバインディング
Gua.Testingロケーター、待機、アサーション、診断
Gua.Runtimeengine adapter向け共有runtime C ABI wrapper
Gua.Testing.UnityUnity Editor/Playerのbuild・起動・接続
Gua.Testing.VisualPNGベースライン比較
Gua.Testing.RecordingSemantic操作の記録・再生
Gua.Testing.Godot外部.NETテストからGodotプロセスを制御

Gua.Core

ネイティブC ABIを.NETから扱う最低層。UI Treeと要求・イベントの契約を提供する。

役割
IGuaContextローカル/リモートContextに共通する操作境界。
GuaContextネイティブGua Contextを所有し、node、snapshot、request、eventを操作。
GuaSelectorid、role、text、状態、scopeを表す選択条件。
GuaNodeStatevisible、enabled、value、focused、checked等の観測状態。
GuaAction / GuaEvent外部要求とホストが観測した結果・イベント。
GuaResetsession epochと要求・イベント・履歴の初期化契約。

Gua.Runtime

Gua.Runtimeは、Guaを使うテスト作者ではなく、managed engine adapterの作者向けです。共有gua_runtime C ABIを型付きAPIとして公開し、各adapterがP/Invoke、request queue、screenshot timeout、version公開、Inspector WebSocket bridgeを重複実装するのを防ぎます。GodotやUnity以外のengineへGuaを組み込む場合、または独自UI framework adapterを作る場合に選びます。実装手順はGua.Runtime実装ガイドを参照してください。

Gua.Testing.Unity

UnityPlayerBuilderUnitySceneTestHostで、Unity 6 Windows x64のMono PlayerまたはEditor Play Modeを外部テストへ接続します。Unity実行ファイルの探索、空きportの割り当て、bridge接続、起動・終了時のlog収集をhostへ任せたい場合に利用します。公開APIと対応範囲はUnity API・仕様を参照してください。

Gua.Testing

Coreの上へ、テストで読むための高水準APIを追加する。

役割
GuaAssertionsGetByIdGetByRoleWaitFor...等の入口。
GuaLocatorQueryByRole、ByText、Within、WhereVisible等を連結するselector builder。
GuaNodeSnapshot成功した特定frame/revision時点のノード証拠。
GuaTestSessionテスト前後のresetとstrict leak検出を管理。
GuaAssertionScopeNUnit等の失敗処理と診断オプションをスコープへ適用。
GuaDiagnostics失敗時のUI Tree、ログ、履歴、環境情報を成果物として保存。

Gua.Testing.Godot

Godotプロセスを起動し、ゲーム内WebSocketブリッジへ接続するホスト層。

役割
GodotSceneTestHostシーンの起動、接続、終了、stdout/stderr、スクリーンショットを管理。
GodotSceneTestHostOptionsGodot実行ファイル、project path、headless、port、環境変数、reset policyを指定。
GuaRemoteContextWebSocket越しに最新snapshotを取得し、actionを送るIGuaContext実装。
GuaRemoteUiTreeリモートJSON snapshotを.NETのノード表現へ変換。
GuaScreenshot公開済みPNGの保存結果、絶対パス、寸法等を表す。

Gua.Testing.Visual

明示的に取得したPNGをreview済みbaselineと比較するオプトイン層です。Semantic assertionで「ボタンが表示されている」と確認できても、そのボタンが切れている、重なっている、誤ったassetで描画されている、といった問題は残ります。この差を埋めるのがVisualテストです。pixel threshold、許容差分率、mask、OS/renderer別variant、dimension mismatchを扱います。詳しい導入・CI運用はVisualテスト実践を参照してください。

画面の見た目をbaselineと比較csharp
var result = await GuaVisualAssertions.ExpectScreenshotAsync(
    host.Context, "title-screen", new()
    {
        BaselineDirectory = "baselines",
        ArtifactDirectory = "artifacts/gua",
        BaselineVariant = "windows-unity-mono",
        PixelThreshold = 0.02f,
        MaxDifferentPixelRatio = 0.001,
    });
失敗理由出力ファイル
pixel_differenceexpected.pngactual.pngdiff.pngcomparison.json
baseline_missingactual.pngcomparison.json
dimension_mismatchexpected.pngactual.pngcomparison.json

comparison.jsonには比較名、variant、実画像の寸法、差分metrics、閾値、mask、失敗理由、診断用の絶対baselinePathを記録します。パッケージ自身はHTMLを生成せず、表示と公開はgua-testerのvisual-report Actionが担当します。通常CIではbaselineを自動更新しません。更新は明示的なdeveloper操作に限定し、PNG差分をreviewしてからcommitします。

Gua.Testing.Recording

ログイン、設定変更、購入確認のような複数stepのユーザーフローをSemantic actionとして保存し、回帰テストやbug再現へ再利用する層です。座標ではなくID・role等のSemantic targetを記録し、再生時は各request IDに対応するhost完了eventまで待つため、単なる固定delayのmacroより安定します。詳しい記録・再生方法はRecording実践を参照してください。

操作を記録して再生csharp
var recorder = new GuaRecorder(host.Context);
await recorder.ClickAsync(new(Id: "open-login"));
await recorder.SetValueAsync(new(Id: "password"), password,
    sensitive: true, secretKey: "login-password");
GuaRecordingFile.Save("recordings/login.json", recorder.Recording);

var recording = GuaRecordingFile.Load("recordings/login.json");
await GuaReplayer.ReplayAsync(host.Context, recording, new()
{
    SecretResolver = key => key == "login-password" ? password : null,
});

GuaRecorderGuaReplayerGuaRecordingFileを提供し、固定delayよりSemantic wait conditionを優先できます。機密なset_valueは平文を保存せずsecretKeyだけを記録します。座標fallbackは既定で無効です。