• <legend id='ROqfV'><style id='ROqfV'><dir id='ROqfV'><q id='ROqfV'></q></dir></style></legend>
      <bdo id='ROqfV'></bdo><ul id='ROqfV'></ul>

    <tfoot id='ROqfV'></tfoot>
  • <i id='ROqfV'><tr id='ROqfV'><dt id='ROqfV'><q id='ROqfV'><span id='ROqfV'><b id='ROqfV'><form id='ROqfV'><ins id='ROqfV'></ins><ul id='ROqfV'></ul><sub id='ROqfV'></sub></form><legend id='ROqfV'></legend><bdo id='ROqfV'><pre id='ROqfV'><center id='ROqfV'></center></pre></bdo></b><th id='ROqfV'></th></span></q></dt></tr></i><div id='ROqfV'><tfoot id='ROqfV'></tfoot><dl id='ROqfV'><fieldset id='ROqfV'></fieldset></dl></div>

      <small id='ROqfV'></small><noframes id='ROqfV'>

      1. 存根和模拟时的区别

        Difference between stub and when in mockito(存根和模拟时的区别)
          <tfoot id='HOuNZ'></tfoot>
              • <bdo id='HOuNZ'></bdo><ul id='HOuNZ'></ul>
                <legend id='HOuNZ'><style id='HOuNZ'><dir id='HOuNZ'><q id='HOuNZ'></q></dir></style></legend>

                <small id='HOuNZ'></small><noframes id='HOuNZ'>

              • <i id='HOuNZ'><tr id='HOuNZ'><dt id='HOuNZ'><q id='HOuNZ'><span id='HOuNZ'><b id='HOuNZ'><form id='HOuNZ'><ins id='HOuNZ'></ins><ul id='HOuNZ'></ul><sub id='HOuNZ'></sub></form><legend id='HOuNZ'></legend><bdo id='HOuNZ'><pre id='HOuNZ'><center id='HOuNZ'></center></pre></bdo></b><th id='HOuNZ'></th></span></q></dt></tr></i><div id='HOuNZ'><tfoot id='HOuNZ'></tfoot><dl id='HOuNZ'><fieldset id='HOuNZ'></fieldset></dl></div>

                  <tbody id='HOuNZ'></tbody>
                  本文介绍了存根和模拟时的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 mockito 的新手.

                  I am new to mockito.

                  需要知道存根和何时的区别

                  need to know difference between stub and when

                        1. stub(cpproxy.getBinList()).toReturn(gettestbins());
                        2. when(cpproxy.getBinList()).thenReturn(gettestbins());
                  

                  这两者有什么区别?

                  推荐答案

                  其实它们在技术上是一样的.最初创建 Mockito 时,我们谈论的是存根,因此词汇表遵循了这个想法.后来人们认为用交互而不是技术术语来思考更好,所以词汇遵循when ... then ...风格.词汇的这种变化有助于人们思考对象之间的交互消息传递.这是面向对象语言中最有趣的想法(消息传递)(引用 Alan Kay).

                  Actually they are technically the same. When Mockito was first created, we were talking about stubs, so the vocabulary followed that idea. Later people thought it was better to think in interactions rather that technical terms, so the vocabulary followed the when ... then ... style. This change in vocabulary helps people to think about interactions, messaging between object. Which is the most interesting idea (message passing) thing in an object oriented language (quoting Alan Kay).

                  如今的测试方法已演变为行为驱动开发(来自 Dan North),这几乎是相同的东西,但更多地关注设计时的行为.为了反映这种想法,人们要求 Mockito 提供反映这种变化的 API.因此,您还可以使用 BDDMockito

                  Nowadays testing approach has evolved to Behavior Driven Development (from Dan North), which is almost the same thing but focus even more on the behavior at design time. To reflect that thinking, people asked Mockito to offer an API that reflect that change. So you also use given ... will ... style from BDDMockito

                  given(the_type.performs_that()).willReturn(something)
                  

                  这是我现在最喜欢的词汇,因为我使用测试来驱动我的对象设计.

                  This is my preferred vocabulary now as I use tests to drive my objects design.

                  这篇关于存根和模拟时的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                    <tbody id='A0Rh1'></tbody>

                  <i id='A0Rh1'><tr id='A0Rh1'><dt id='A0Rh1'><q id='A0Rh1'><span id='A0Rh1'><b id='A0Rh1'><form id='A0Rh1'><ins id='A0Rh1'></ins><ul id='A0Rh1'></ul><sub id='A0Rh1'></sub></form><legend id='A0Rh1'></legend><bdo id='A0Rh1'><pre id='A0Rh1'><center id='A0Rh1'></center></pre></bdo></b><th id='A0Rh1'></th></span></q></dt></tr></i><div id='A0Rh1'><tfoot id='A0Rh1'></tfoot><dl id='A0Rh1'><fieldset id='A0Rh1'></fieldset></dl></div>

                    • <bdo id='A0Rh1'></bdo><ul id='A0Rh1'></ul>

                      <tfoot id='A0Rh1'></tfoot>

                        <small id='A0Rh1'></small><noframes id='A0Rh1'>

                      1. <legend id='A0Rh1'><style id='A0Rh1'><dir id='A0Rh1'><q id='A0Rh1'></q></dir></style></legend>