1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pesterのアサーションオぺレーターにおける入力配列の扱い

Last updated at Posted at 2019-01-07

Pesterによるテストコードは

$actual | Should -<Operator>

と書かれるが、$actualが配列だった場合に、1要素ずつアサーションを実行するのか、配列全体を受け取ってアサーションするかどうかは、オペレーターごとに定義されている。

まとまったドキュメントが見つからなかったので、ソース(Functions/Assertions/.ps1)から拾い上げた。
下表のarray supported
true* の場合、配列全体を受け取るオペレータ、falseの場合、1要素ずつ受け取るオペレータ。

operator array supported
Be true 1
BeExactly true 1
BeGreaterThan false
BeLessOrEqual false
BeIn false
BeLessThan false
BeGreaterOrEqual false
BeLike false
BeLikeExactly false
BeNullOrEmpty true
BeOfType false
BeTrue false
BeFalse false
Contain true
Exist false
FileContentMatch false
FileContentMatchExactly false
FileContentMatchMultiline false
HaveCount true
Match false
MatchExactly false
Throw false
  1. 内部で、配列の要素単位でアサーションを実行しているため、実質falseと同等。入れ子になった配列を扱うためにtrueになっている模様 2

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?