2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHPUnitでテスト件数がずれる。

Posted at

PHPUnitでテスト件数がずれる。

LaravelにてPHPUnitでテストコードを実行したところ、実際の件数とコンソールに出力される件数がずれる事象が発生

原因

テストデータのキーが重複していたこと

/**
*テストデータ提供メソッド
**/
public function provider(): array {
  return [
    '正常系' => [1, 2, 3],
    '正常系' => [1.1, 2.2., 3.3]
  ];

↑テストデータのキーが正常系で重複しているので1件とカウントされる。

/**
*テストデータ提供メソッド
**/
public function provider(): array {
  return [
    '正常系_int' => [1, 2, 3],
    '正常系_double' => [1.1, 2.2., 3.3]
  ];

↑上記なら想定通り2件とカウントされる。

2
0
0

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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?