loopbackio / loopbackio/loopback-next

Testing your Application: explain why interdependent tests are bad

オープン 初心者向け
#683 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Docs good first issue help wanted
主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
2日 21時間
マージ済み PR(30日)
27

説明

In https://github.com/strongloop/loopback4-example-getting-started/pull/2, the proposed acceptance tests are relying on the first test to fill the database with data that's used by subsequent tests:

  it('creates a todo', async () => {
    item = (await client
      .post('/todo')
      .send(payload)
      .expect(
        Object.assign({}, payload, {
          id: 1
        })
      )).body;
  });

  //...

  it('successfully deletes todos', async () => {
    await client.del(`/todo/${item.id}`).send();
    await client
      .get(`/todo/${item.id}`)
      .send()
      .expect(404);
  });

(see https://github.com/strongloop/loopback4-example-getting-started/pull/2#discussion_r147389550)

This is an anti-pattern to avoid:

  • if the first test fails, all subsequent tests fail too (because data was not filled in), but with an unhelpful error message is confusing.
  • it is not possible to run individual tests on their own, e.g. via it.only() or mocha -g "test name".

We should extend Data Handling in Testing your Application to mention this pattern and explain why it's a bad thing to do.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue にリンクされている「Data Handling in Testing your Application」セクションから始め、コンテキストを把握するために、参照されているサンプルテストと pull request の議論を読んでください。相互依存するテストがなぜ問題になるのか、また独立したテストがどのように分離実行を支えるのかを説明するようにドキュメントを更新してください。完了条件は、失敗の連鎖と it.only()/mocha -g の使用の両方が扱われていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。