"Integrated practice on the subject of software engineering" --Unity brief testing tools

Introduction Unity 3d platform test tool --Editor Tests Runner Testing Tools

 

background:

As a novice a game developer, I feel Unity to develop some game very convenient, but there are many published to the Android client may appear this kind of problem, the developer provides a lot of optimization strategy for us, and here I talk about the main test for the Unity of tools --Editor Tests Runner.

I. Introduction Tool

The test tool is Unity Unity Test Runner, which is based on the NUnit, and increased  UnityTestAttribute to provide a current frame skip function, which relates to the  Update() useful life cycle testing functions, for example,  GameObject motion testing.

II. Unit testing

Defined for unit testing: Unit testing is very important tool in the conventional software development, it refers to software smallest testable unit checking and validation, in general, is the code of a function to verify, check its correctness. Automated unit testing is a section of code, the code calls the work unit being tested, after some assumptions about the final result of this single unit for testing. Write unit tests using the test frame unit, and the unit test requires reliable, readable and maintainable. As long as the product code is not changed, the result of unit testing is stable.

Unit testing allows you to find Bug in the early stages of software development, rather than to integration testing when it is discovered, developed a module (class, function) to do a unit test correspondingly, to find and dispose of bug as soon as possible, improve code the quality of. (Anyway, unit testing can not do without! Effect is really good)

III. Use Introduction

 First, we can find something in the engine Window Test Runner tool (different versions in different places, but in Window where you can turn it look). Open as follows:

 

Then, click on "CREATE EDITMODE" will jump to the following screen:

After clicking, you will automatically create the following directory Tests folder, and a default test script named script Vs open for editing:

 

Here mainly added some assertions in the statement of operations inside the software simple test

脚本编写完成之后,回到Unity引擎中的Test Runner界面处,点击左上方的Run All之后,这些代码会自动运行并进行检测,结果如下:

可以看到都通过了测试。

Unity作为一款好用的游戏引擎,也提供了一些其他的测试方法。如果你需要一次执行多个代码段,可以尝试在传入参数时加入批处理命令的参数:

  • runEditorTests
  • editorTestsResultFile
  • editorTestsFilter
  • editorTestsCategories
  • editorTestsVerboseLog

 

 

四.注意

测试函数要标上 [Test] 或者 [UnityTest] 属性才会被 Test Runner 识别,前者是普通测试,后者具有跳过帧的能力(可使用 yield return null,根据测试模式决定是跳 EditorApplication.update 还是 update)。

Unity Test Runner 使用 NUnit 3.5 版本。

 

这学期最后一次博客也完成了,除了这次也没有什么机会写一些总结了。

刚开始上这门课的时候,我觉得这节课事情太多了,几乎周周博客,周周任务。但是到后来才发现,通过写博客可以让自己对这方面的知识了解的更加深刻(不然要是错了让大家看到也未免太丢人了!)。另外,这学期作为小组的组长,协调分配成员的分工任务,通过几次交流和报告,自己的这方面能力也有所提高。最后一次博客了,这次因为我们的期末成品比较特殊,是在游戏引擎上开发的,对这方面的测试内容一直不是很了解,也从来没有想到过要在这里执行测试,但是测试之后还是发现也能发现其中的一些问题,总的来说收获不小。还有就是,老师辛苦啦!

 

Guess you like

Origin www.cnblogs.com/HiangXuUp/p/10962130.html