タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

pytestに関するyubessyのブックマーク (2)

  • pytestでテストケースの前後処理をする - Qiita

    はじめに (TL;DR) 初投稿です。どうぞよろしくお願いします。 さて、今回はpytestで前後処理の記述方法について紹介します。 Javaっとした世界でいうところのbeforeClassやafterClass等ですね。 目的としてはこんなところでしょうか。 前後処理などセットアップコードを共通化したい setup処理からparameterを引き渡したい テストケースごとに固有の前後処理をしたい では、ゴタックーを並べるのはその辺にして、早速見ていきましょう。 構成 pytestの世界では、セットアップコードをconftest.pyと呼ばれる別ファイルに外だしするのがお作法なようです。 従って、ディレクトリは例えば以下のように切ります。 tests ├── __init__.py └── sample ├── __init__.py |── conftest.py # セットアップコード

    pytestでテストケースの前後処理をする - Qiita
  • About fixtures — pytest documentation

    pytest fixtures are designed to be explicit, modular and scalable. What fixtures are¶ In testing, a fixture provides a defined, reliable and consistent context for the tests. This could include environment (for example a database configured with known parameters) or content (such as a dataset). Fixtures define the steps and data that constitute the arrange phase of a test (see Anatomy of a test).

  • 1