Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

テストのカテゴリ化 #26

Closed
bleis-tift opened this issue Oct 29, 2014 · 3 comments
Closed

テストのカテゴリ化 #26

bleis-tift opened this issue Oct 29, 2014 · 3 comments
Milestone

Comments

@bleis-tift
Copy link
Contributor

No description provided.

@bleis-tift
Copy link
Contributor Author

テストエクスプローラの「特徴」によるフィルタリングで使える気がする。モデルには何らかの情報として持たせておきたいが、今すぐ活用するかと言うと疑問。

@pocketberserker pocketberserker modified the milestones: 3.0.0, Unscheduled Nov 11, 2016
@hafuu
Copy link
Contributor

hafuu commented Oct 1, 2017

テストのカテゴリ化について考えてみました。

TestMetadata 型に val Categories : string[] プロパティを追加する。
TestMetadata を継承している型は TestCaseContext がある。

type TestMetadata =
  val Name : string
  val Categories : string[]
  ...

カテゴリの設定方法

1. テストケースに設定する

下記シグネチャの関数で、テストケースにカテゴリを設定する

val category : name:string -> test:TestCase<'T> -> TestCase<'T>

// テストにカテゴリを設定する
let test1 = test { do! pass() } |> category "CategoryA"

// パラメタライズテスト
let test2 = parameterize {
  source [ 1 ]
  run (fun _ -> test { do! pass() } |> category "CategoryB")
}

2. モジュール配下の全テストに設定する

下記属性をモジュールに付けると、モジュール配下の全テストにカテゴリが設定される

type CategoryAttribute = class end

[<Category("CategoryC")>]
module SomeTest =
  // "CategoryC" というカテゴリが設定される
  let test3 = test { do! pass() }
  
  // "CategoryC" と "CastegoryD" が設定される
  let test4 = test { do! pass() } |> category "CategoryD"
  
  [<Category("CategoryE")>]
  module NestedModule =
    // "CategoryC" と "CategoryE" が設定される
    let test5 = test { do! pass() }

カテゴリの実行方法

指定したカテゴリを実行する

Persimmon.Console.exe tests.dll --category:CategoryA,CategoryB

指定したカテゴリ以外を実行する

Persimmon.Console.exe tests.dll --exclude-category:CategoryD,CategoryE

その他

1. テストを合成した場合はカテゴリについて

次のような場合に、 test1CategoryAは引き継がず、test2のカテゴリは無しとする。

let test1 = test { return 1 } |> category "CategoryA"
let test2 = test {
  let! x = test1
  do! x |> assertEquals 1
}

@hafuu hafuu mentioned this issue Oct 5, 2017
3 tasks
@pocketberserker
Copy link
Contributor

implemented #126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants