このリポジトリには Windows 向けの xUnit テストプロジェクトとして tests\PerformanceMonitorAnalyzer.Tests\PerformanceMonitorAnalyzer.Tests.csproj を追加しています。
- プロジェクト:
tests\PerformanceMonitorAnalyzer.Tests\PerformanceMonitorAnalyzer.Tests.csproj - ターゲットフレームワーク:
net10.0-windows - 参照先:
src\PerformanceMonitorAnalyzer\PerformanceMonitorAnalyzer.csproj
Microsoft.NET.Test.Sdk17.14.1xunit2.9.3xunit.runner.visualstudio3.1.4coverlet.collector6.0.4
すべて固定バージョンで指定しており、浮動バージョンは使用していません。
リポジトリのルートディレクトリで次のコマンドを実行します。
dotnet test tests\PerformanceMonitorAnalyzer.Tests\PerformanceMonitorAnalyzer.Tests.csproj -v minimal初期セットアップ確認用として、アプリ本体の PerformanceDataPoint 型を参照できることを確認する最小限のスモークテストを配置しています。
今後はこのプロジェクトに機能単位のユニットテストを追加してください。
tests\PerformanceMonitorAnalyzer.Tests\CounterPatternTests.cs では、カウンターパターン設定の scale / graphType / valueMode 読み込みを次の観点で検証しています。
- YAML に明示した
scale/graphType/valueModeがCounterPattern/CounterDefinitionに反映されること - YAML で
scale/graphType/valueModeを省略した場合でも既定値1.0/lineChart/rawValueが維持されること 0以下などの無効なscaleが指定された場合は既定値1.0に補正されること- 設定ファイル未配置時に生成される既定設定で、明示的な
scaleサンプルとgraphType/valueModeを含めた既定値が両立したまま再読み込みできること
検証時は出力先の競合を避けるため、必要に応じて OutputPath を一時ディレクトリへ切り替えて実行します。
dotnet test --nologo -v q -p:OutputPath=<temp path> -p:SelfContained=false -p:UseAppHost=false tests\PerformanceMonitorAnalyzer.Tests\PerformanceMonitorAnalyzer.Tests.csprojtests\PerformanceMonitorAnalyzer.Tests\CounterPathPatternMatcherTests.cs では、\オブジェクト(インスタンス)\* 形式のパターンが該当オブジェクト配下の全カウンターへ一致することと、SQL Server のようにインスタンス名内にかっこを含むケースでも正しく扱えることを検証しています。