タグ

mockとrailsに関するchanpon0のブックマーク (2)

  • What are mock and stub used in unit testing? • No Programming, No Life

    This article is a simple explanation of mock and stub used in unit testing. What is stub? A stub is a small program routine that substitutes for a longer program. You should use a stub in order to pass to the code under test. What is mock? Mock is a method/object that simulates the behavior of a real method/object. A mock is an object that we can set expectations on, and which will verify that the

  • 使えるRSpec入門・その3「ゼロからわかるモック(mock)を使ったテストの書き方」 - Qiita

    はじめに みなさんこんにちは! この記事は「必要最小限の努力で最大限実戦で使える知識を提供するRSpec入門記事」、略して「使えるRSpec入門」の第3回です。 今回はRSpecのモックを使ったテストについて説明します。 これまでモックを全く使ったことがない人でもわかるように丁寧に説明していくつもりです。 また、これまでの回と同様、個人的に使用頻度が低いと思っている内容についてはバッサリ説明を省きます。 ただし、第1回や第2回に比べるとテストコードが少し複雑になって、仕組みや動きを想像するのがちょっと難しいかもしれません。 ぱっと頭に入ってこない場合はじっくり文を読んだり、実際に自分で写経しながらコードを動かしたりするなどして、少し時間をかけながら理解するようにしてください。 今回は以下のような内容を説明します。 モックの基的な使い方 モックを使った検証 モックでわざとエラーを発生させ

    使えるRSpec入門・その3「ゼロからわかるモック(mock)を使ったテストの書き方」 - Qiita
  • 1