unity3d的驱动接口_Unity 3d中的测试驱动开发(TDD)

论坛 期权论坛     
选择匿名的用户   2021-5-30 01:53   346   0
<div style="font-size: 16px;">
<p>unity3d的驱动接口</p>
<p>Test-driven development (TDD) is the practice of writing automated tests for a piece of code before writing the code itself. This basically means that we create and refactor (changing structure without changing behaviour) our project code on the basis of tests. The process of writing the code, testing the code and refactoring it all follow each other in a loop, until a satisfactory state is reached.</p>
<p> 测试驱动开发(TDD)是在编写代码本身之前为一段代码编写自动化测试的实践。 这基本上意味着我们根据测试来创建和重构(在不改变行为的情况下更改结构)我们的项目代码。 编写代码,测试代码以及对其进行重构的过程都是相互循环的,直到达到令人满意的状态。 </p>
<p>The following sequence of steps is generally followed:</p>
<p> 通常遵循以下步骤顺序: </p>
<ul><li><p> Add a test (that will initially fail) </p><p> 添加测试(最初会失败) </p></li><li><p> Run all tests and see if the new one fails </p><p> 运行所有测试,看看新测试是否失败 </p></li><li><p> Write some code </p><p> 写一些代码 </p></li><li><p> Run tests </p><p> 运行测试 </p></li><li><p> Refactor code </p><p> 重构代码 </p></li><li><p> Repeat </p><p> 重复 </p></li></ul>
<p>Following this workflow speeds up the process of refactoring code and making changes, because you can see straight away what has broken and why. </p>
<p> 遵循此工作流程可以加快代码重构和更改的过程,因为您可以立即看到发生问题的原因。 </p>
<p>You may wonder why we write the test before writing the code itself. This is because writing tests after writing the code can often lead to developers writing tests to make them pass. When you write a failing test first, you’re making sure that it fails for a good reason (such as not implementing the required functionality correctly), as well as ruling out false positives. </p>
<p> 您可能想知道为什么我们在编写代码本身之前就编写测试。 这是因为在编写代码之后编写测试通常会导致开发人员编写测试以使其通过。 当您首先编写失败的测试时,您要确保它有充分的理由失败(例如未正确实现所需的功能),并排除误报。 </p>
<h2> 红绿重构循环 <span style="font-weight: bold;">(</span>Red-Green Refactor Loop<span style="font-weight: bold;">)</span></h2>
<div style="text-align: center;">
  <img alt="Red-green-refactor-loop" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-dd1333961725c39bd3d06abb721b597b" style="outline: none;">
</div>
<p>The most important thing to keep in mind is the red-green-refactor loop. It is the heart and soul of the TDD process. Here each step has a meaning:</p>
<p> 要记住的最重要的事情是红绿色重构循环。 这是TDD进程的灵魂。 这里的每个步骤都有其含义: </p>
<ol><li><p><b>RED:</b> It refers to writing a test case that will definitely fail.</p><p> <b class="raw_b_node">RED:</b>这是指编写肯定会失败的测试用例。 </p></li><li><p><b>GREEN:</b> It refers to changing/writing code that will make the test created in the “RED” phase pass in such a way that all the tests that passed previously will still pass. This means that the developer must not break the working of the project to just pass one test. </p><p> <b class="raw_b_node">绿色:</b>它是指更改/编写代码,这些代码将使在“红色”阶段创建的测试通过,从而使先前通过的所有测试仍然通过。 这意味着开发人员不得仅通过一项测试就中断项目的工作。 </p></li><li><p><b>REFACTOR:</b> It refers to eliminating redundancy, increasing readability, etc of the code written. </p><p> <b class="raw_b_node">参考:</b>这是指消除编写的代码的冗余,提高可读性等。 </p></li></ol>
<p>These steps are repeated over and over again until all tests pass or encountering a failing test is impossible/improbable.</p>
<p> 一遍又一遍地重复这些步骤,直到不可能/不可能通过所有测试或失败的测试为止。 </p>
<h2> 单元测试 <span style="font-weight: bold;">(</span>Unit Testing<span style="font-weight: bold;">)</span></h2>
<p>UNIT TESTING is a level of software testing where individual units/ components of a software are tested. The purpose is to validate that each unit of the software performs as designed. A unit is the smallest testable part of any software. It usually has one or a few inputs and usually a single output. </p>
<p> 单元测试是软件测试的级别,其中测试软件的各个单元/组件。 目的是验证软件的每个单元是否按设计执行。 单元是所有软件中最小的可测试部分。 它通常只有一个或几个输入,通常只有一个输出。 </p>
<h3> 时间为例! <span style="font-weight: bold;">(</span>Time for an Example!<span style="font-weight: bold;">)</span></h3>
<p>Now what we believe is that action speaks louder than words. Hence, performing a task is the best form of learning. Hence what we will aim for is to set up a basic unit
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP