Files
everything-claude-code/docs/ja-JP/rules/fsharp/testing.md
Claude ec9ace9c54 docs: add native Japanese translation of ECC documentation (ja-JP)
Translate everything-claude-code repository to Japanese including:
- 17 root documentation files
- 60 agent documentation files
- 80 command documentation files
- 99 rule files across 18 language directories (common, angular, arkts, cpp, csharp, dart, fsharp, golang, java, kotlin, perl, php, python, ruby, rust, swift, typescript, web)
- 199 skill documentation files

Total: 455 files translated to Japanese with:
- Consistent terminology glossary applied throughout
- YAML field names preserved in English (name, description, etc.)
- Code blocks and examples untouched (comments translated)
- Markdown structure and relative links preserved
- Professional translation maintaining technical accuracy

This translation expands ECC accessibility to Japanese-speaking developers and teams.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-17 02:31:40 -04:00

2.3 KiB

paths
paths
**/*.fs
**/*.fsx
**/*.fsproj

F# テスト

このファイルは common/testing.md を F# 固有のコンテンツで拡張します。

テストフレームワーク

  • F# フレンドリーなアサーションのために xUnitFsUnit.xUnit を優先する
  • 明確な失敗メッセージを持つクォーテーションベースのアサーションには Unquote を使用する
  • プロパティベーステストには FsCheck.xUnit を使用する
  • 依存関係のモックには NSubstitute または関数スタブを使用する
  • インテグレーションテストで実際のインフラが必要な場合は Testcontainers を使用する

テストの構成

  • tests/ 配下に src/ の構造を反映させる
  • ユニット、インテグレーション、エンドツーエンドのカバレッジを明確に分離する
  • 実装の詳細ではなく、振る舞いでテストに名前を付ける
open Xunit
open Swensen.Unquote

[<Fact>]
let ``リクエストが有効な場合、PlaceOrder は成功を返す`` () =
    let request = { CustomerId = "cust-123"; Items = [ validItem ] }
    let result = OrderService.placeOrder request
    test <@ Result.isOk result @>

[<Fact>]
let ``アイテムが空の場合、PlaceOrder はエラーを返す`` () =
    let request = { CustomerId = "cust-123"; Items = [] }
    let result = OrderService.placeOrder request
    test <@ Result.isError result @>

FsCheck を使ったプロパティベーステスト

open FsCheck.Xunit

[<Property>]
let ``注文合計が負になることはない`` (items: OrderItem list) =
    let total = Order.calculateTotal items
    total >= 0m

ASP.NET Core インテグレーションテスト

  • API インテグレーションカバレッジには WebApplicationFactory<TEntryPoint> を使用する
  • ミドルウェアをバイパスするのではなく、HTTP を通じて認証、バリデーション、シリアライゼーションをテストする

カバレッジ

  • 80%以上の行カバレッジを目標とする
  • ドメインロジック、バリデーション、認証、失敗パスのカバレッジに重点を置く
  • 利用可能な場合はカバレッジ収集を有効にして CI で dotnet test を実行する