d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
2.3 KiB
2.3 KiB
paths
| paths | |||
|---|---|---|---|
|
F# テスト
このファイルは common/testing.md を F# 固有のコンテンツで拡張します。
テストフレームワーク
- F# フレンドリーなアサーションのために xUnit と FsUnit.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を実行する