stubbing
スタブ化
解説 Definition
テスト目的で関数やオブジェクトの実装を簡略版に置き換えるプログラミング手法。依存関係を隔離して単体テストを可能にする。
Stubbing is the act of creating or using a simple replacement part, called a stub, during software development or testing. It helps developers test one part of a program without needing the full real system. The term is mainly used in programming.
覚え方のコツ Memory Tip
stubbing はまず stub を核に覚える。stub は「中身は作り込まず、入口だけ合わせた短い代用品」という感覚。だから stubbing は、本物の実装を全部書かず、最低限の返り値だけ返す部品に差し替えること。単体テストで DB・外部 API・重い処理を切り離す場面と結びつけると定着しやすい。mock が「どう呼ばれたかを検証する」寄りなのに対し、stub は「こう返すと決めてテストを進める」寄り。stub out a method, use stubs in tests の形でも覚える。
Remember the core word `stub`: a small, simple replacement, not the real thing. In programming, connect `stubbing` with tests where you do not call the real database or API, but use a basic stand-in instead. It also helps to contrast it with `mock`, which often focuses more on checking how something was called.
例文
Stubbing the function allows testing without implementation.
関数をスタブ化すれば、実装なしでテストできる。
Developers use stubbing to isolate code units.
開発者はスタブ化によってコード単位を隔離する。
Stubbing simplifies complex test scenarios.
スタブ化は複雑なテストシナリオを単純化する。
stubbing の類義語・関連語
stubbing の語源・成り立ち Etymology
stubbing は stub「切り株・短く切られたもの」に動名詞語尾 -ing が付いた語です。stub は古英語 stybb にさかのぼり、元は「先だけ残った短いもの」の意なので、技術用語では本物の代わりに短い代用品を作る感覚で「スタブ化」になります。関連語は stub, stubby。
`Stubbing` comes from `stub` with the ending `-ing`. `Stub` goes back to Old English `stybb`, meaning a stump or a short remaining piece. The basic idea is something cut off so that only a short end remains, and from that it developed into uses for making short substitute forms in technical contexts. A related word is `stubby`.
外部辞書で調べる
この単語を英単語クイズで覚えよう