存根与mockito之间的区别

编程入门 行业动态 更新时间:2024-10-21 03:32:59
本文介绍了存根与mockito之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是simito的新手。

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());

这两者之间有什么区别?

whats the difference between these two?

推荐答案

实际上它们在技术上是一样的。当Mockito第一次创建时,我们讨论的是存根,所以词汇表遵循了这个想法。后来人们认为最好在交互而不是技术术语中思考,所以词汇表遵循时......然后...... 样式。 这种词汇量的变化有助于人们在对象之间考虑交互,消息。面向对象语言中哪个是最有趣的想法(消息传递)( 引用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.

更多推荐

存根与mockito之间的区别

本文发布于:2023-10-31 04:46:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存根   区别   mockito

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!