添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
考研的葡萄
·
南京市人民政府
·
5 月前
·
温柔的围巾
·
研院新闻-华中师范大学研究生院
·
7 月前
·
咆哮的抽屉
·
LINQ优化:将GroupBy换做Disti ...
·
7 月前
·
没有腹肌的黑框眼镜
·
小红帽直播app最新版本下载-小红帽直播20 ...
·
7 月前
·
风度翩翩的钢笔
·
springboot-guide/docs/ ...
·
9 月前
·
link管理
›
Fake class - mockito library - Dart API
string
mockito
dart
https://pub.dev/documentation/mockito/latest/mockito/Fake-class.html
斯文的豆浆
4 月前
</noscript><div id="overlay-under-drawer"/><header id="title"><span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span><a class="hidden-xs" href="/"><img src="/static/hash-dntl8ks4/img/dart-logo.svg" alt="" width="30" height="30" role="presentation" style="height: 30px; margin-right: 1em;"/></a><ol class="breadcrumbs gt-separated dark hidden-xs"><li><a href="/packages/mockito">mockito package</a></li><li><a href="../index.html">documentation</a></li><li><a href="../mockito/mockito-library.html">mockito.dart</a></li><li class="self-crumb">Fake class</li></ol><div class="self-name">Fake class</div><form class="search navbar-right" role="search"><input id="search-box" class="form-control typeahead" type="text" placeholder="Loading search..." autocomplete="off"/></form><div id="theme-button" class="toggle" title="Toggle brightness"><label for="theme"><input id="theme" type="checkbox" value="light-theme"/><span id="dark-theme-button" class="material-symbols-outlined">dark_mode</span><span id="light-theme-button" class="material-symbols-outlined">light_mode</span></label></div></header><main><div id="dartdoc-main-content" class="main-content" data-above-sidebar="mockito/mockito-library-sidebar.html" data-below-sidebar="mockito/Fake-class-sidebar.html"> <h1><span class="kind-class">Fake</span> class <a href="https://dart.dev/language/class-modifiers#abstract" class="feature feature-abstract" title="This type can not be directly constructed.">abstract</a> <a href="https://dart.dev/language/mixins" class="feature feature-mixin" title="This class can be used as a class and a mixin.">mixin</a> <p>A stand-in for another object which cannot be used except for specifically overridden methods.</p> <p>A fake has a default behavior for every field and method of throwing <a href="https://api.dart.dev/stable/3.5.2/dart-core/UnimplementedError-class.html" rel="ugc">UnimplementedError</a>. Fields and methods that are exercised by the code under test should be manually overridden in the implementing class.</p> <p>A fake does not have any support for verification or defining behavior from the test, it cannot be used as a mock.</p> <p>In most cases a shared full fake implementation without a <code>noSuchMethod</code> is preferable to <code>extends Fake</code>, however <code>extends Fake</code> is preferred against <code>extends Mock</code> mixed with manual <code>@override</code> implementations.</p> <p><strong>Example use</strong>:</p> <pre class="language-dart"><code>// Real class. class Cat { String meow(String suffix) => 'Meow$suffix'; String hiss(String suffix) => 'Hiss$suffix'; // Fake class. class FakeCat extends Fake implements Cat { @override String meow(String suffix) => 'FakeMeow$suffix'; void main() { // Create a new fake Cat at runtime. var cat = new FakeCat(); // Try making a Cat sound... print(cat.meow('foo')); // Prints 'FakeMeowfoo' print(cat.hiss('foo')); // Throws <p><strong>WARNING</strong>: <a href="../mockito/Fake-class.html">Fake</a> uses <a href="goo.gl/r3IQUH">noSuchMethod</a>, which is a <em>form</em> of runtime reflection, and causes sub-standard code to be generated. As such, <a href="../mockito/Fake-class.html">Fake</a> should strictly <em>not</em> be used in any production code, especially if used within the context of Dart for Web (dart2js, DDC) and Dart for Mobile (Flutter).</p>
推荐文章
考研的葡萄
·
南京市人民政府
5 月前
温柔的围巾
·
研院新闻-华中师范大学研究生院
7 月前
咆哮的抽屉
·
LINQ优化:将GroupBy换做Distinct - ojdev - 博客园
7 月前
没有腹肌的黑框眼镜
·
小红帽直播app最新版本下载-小红帽直播2024回归地址下载v3.3.7-手游之家
7 月前
风度翩翩的钢笔
·
springboot-guide/docs/basis/springboot-jpa.md at master · CodingDocs/springboot-guide · GitHub
9 月前