Test tools used in the project [cum software engineering practices fifth individual assignments]

[Comprehensive practice on the subject of software engineering]

- Use the test tool project

[Jewish]SHOU 1759223

table of Contents:

"Integrated software engineering practice on the subject" ················ 1

1. The importance of software testing ···················· 2

2. In what software testing period the most appropriate ·························· 3 

3.Unity unit testing tools ································ 4

4.Unity unit testing tool ···················· 5

5.Unity performance testing ············································ 6

6. Learn sentiment ············································ 7

Page2 importance of software testing

       Software testing his aim is to ensure the quality of the software, confirm that software the right way do you expect things, so his work is mainly found in the wrong software effectively define and implement software components from the low to high assembly process , verify that the software meets the technical requirements specified in the mission statement and system definition document that provides the basis for the establishment of software quality model.
       And software testing is not only to ensure the quality of the software, but also to provide information to developers to facilitate their make appropriate preparations for the risk assessment, it is important to him throughout the entire software development process, ensure that the entire software development process is of high quality. As the materials cited six examples, they illustrate the essential software testing during the entire software development process, and if the defect can be found early Patriot missile defense system would not have Elegy of 28 souls; If we can be effective software testing as soon as possible, perhaps the "millennium bug" will be strangled in the cradle, then tens of billions of dollars in damage costs will be able to facilitate and enhance the comprehensive national strength of a century; when if at the beginning of the Lion King find bugs in the program, it does not give the children's childhood does not bring happy memories and shadows. It is these small errors led to a huge response, so we have to pay attention to software testing, software testing correct understanding of the crucial determinant in the whole process of software development, errors may be only the most simple input of the decades of hard work destroyed.
Page3 when to begin the test most appropriate
      to emphasize in the software life cycle, software testing after the software design and coding procedures, carried out before the software runs most appropriate. But my personal findings, taking into account the Bug testers to find in the software development process, to avoid defects in the software development process, focusing on the needs of users and other tasks, so as a software developer, software testing to be embedded throughout the software development process, such as program design and coding phases of the software had to be embedded part of the software testing should always check the feasibility of the software, but as a professional software testing, or after the program code, before the most appropriate software to run.

Page4 Unity Unit testing tools

      There are many mature unit testing framework can be for our use, I would rather recommend is Unity Editor comes with Editor Tests Runner, features small, but has been good enough, very easy to use. Editor Tests Runner is open source unit testing tool NUnit implemented in Unity engine, NUnit version is currently using Unity 2.6.4. Editor Tests Runner by Window -> General-> Tests Runner menu opens, it looks as shown below:

 

 

Produces the following window:

 

 

2. Click create test will generate the following files in the project, as:

 

 

Page5 Unity unit testing tool

1 shows the current adding unit test cases, and in this case through their window. First, you need to click on the top left corner of the window Run All button to perform all the unit tests. A green check mark indicates that this use case through unit testing, red symbol indicates that no prohibition unit tests. Here we look at how to write a unit test code. Unit testing code and runtime code is saved games separately, it is only available in Editor environment, so you need to put it under the Editor directory.

First For the following test, we first define a custom type of error exception, spare advance. It only needs to inherit directly ApplicationException on it, the code is as follows:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

/// <summary>

/// custom exception type

/// </summary>

class NegativeHealthException : ApplicationException

{

 

}

 

2. Now we need to write a module or the code being tested, interface, we need to look at run-time software and the like. Code as follows:

using System.Collections;

using System.Collections.Generic;

using NUnit.Framework;

using UnityEngine;

using UnityEngine.TestTools;

 

namespace Tests

{

    public class NewTestScript1

    {

        GameObject str;

        void Start()

        {

            Debug.Log("StartTime=" + Time.time);

        }

        void Update()

        {

            Debug.Log("Time=" + Time.time);

        }

 

        // A Test behaves as an ordinary method

        [Test]

        public void NewTestScriptSimplePasses()

        {

            string a = Time.time.ToString();

            Assert.IsEmpty(a, "成功", str);

        }

 

        // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use

        // `yield return null;` to skip a frame.

        [UnityTest]

        public IEnumerator NewTestScriptWithEnumeratorPasses()

        {

            // Use the Assert class to test conditions.

            // Use yield to skip a frame.

            yield return null;

        }

    }

}

我们可以点击左上角run all:发现通过测试

 

 

3.  界面中我们需要判单在AR模式中连接EasyAR插件是否成功:

using UnityEngine;

using EasyAR;

 

namespace EasyARSample

{

    public class HelloARTargetTest : MonoBehaviour

    {

        private const string title = "Please enter KEY first!";

        private const string boxtitle = "===PLEASE ENTER YOUR KEY HERE===";

        private const string keyMessage = ""

            + "Steps to create the key for this sample:\n"

            + "  1. login www.easyar.com\n"

            + "  2. create app with\n"

            + "      Name: HelloARMultiTarget-SameImage (Unity)\n"

            + "      Bundle ID: cn.easyar.samples.unity.helloarmultitarget.si\n"

            + "  3. find the created item in the list and show key\n"

            + "  4. replace all text in TextArea with your key";

 

        private void Awake()

        {

            if (FindObjectOfType<EasyARBehaviour>().Key.Contains(boxtitle))

            {

#if UNITY_EDITOR

                UnityEditor.EditorUtility.DisplayDialog(title, keyMessage, "OK");

#endif

                Debug.LogError(title + " " + keyMessage);

            }

        }

    }

}

运行测试后,我们可以发现在控制器里面多了如下结果,说明连接成功:

 

 

Page6 Unity性能测试

性能测试方面,我们可以使用Unity自带的Profile可以用来对程序性能(内存占用、渲染瓶颈)进行查看、分析,当应用程序发布出来之后,还能通过Profile对应用程序真机进行测试,对不同设备兼容性进一步测试。

Android使用Profile:

    1.关闭手机数据流量

    2.打开wifi(确保手机和unity所在pc在同一局域网)

3.使用unity打包apk,打包时需要勾选

 

 

4.在手机段启动apk应用,

 

 

5.profiler自动弹出并显示手机运行apk的真实参数

音频

 

 

CPU使用

 

 

 

显示内存:

 

 

 

6.如果 Unity 编辑器 (Editor) 自动连接设备失败,从分析器窗口 (Profiler Window) 的活动分析器 (Active Profiler) 下拉菜单中选择正确的设备

7.最后就能在Unity中调试显示内存等暂用信息:

有以下参数可以参考:

System.ExecutableAndDlls:系统可执行程序和DLL,是只读的内存,用来执行所有的脚本和DLL引用。不同平台和不同硬件得到的值会不一样,可以通过修改Player Setting的Stripping Level来调节大小。

Ricky:我试着修改了一下Stripping Level似乎没什么改变,感觉虽占用内存大但不会影响游戏运行。我们暂时忽略它吧(- -)!

GfxClientDevice:GFX(图形加速\图形加速器\显卡 (GraphicsForce Express))客户端设备。

Ricky:虽占用较大内存,但这也是必备项,没办法优化。继续忽略吧(- -)!!

ManagedHeap.UsedSize:托管堆使用大小。

Ricky:重点监控对象,不要让它超过20MB,否则可能会有性能问题!

ShaderLab:Unity自带的着色器语言工具相关资源。

SerializedFile:序列化文件,把显示中的Prefab、Atlas和metadata等资源加载进内存。

Ricky:重点监控对象,这里就是你要监控的哪些预设在序列化中在内存中占用大小,根据需求进行优化。

PersistentManager.Remapper:持久化数据重映射管理相关

Ricky:与持久化数据相关,比如AssetBundle之类的。注意监控相关的文件。

ManagedHeap.ReservedUnusedSize:托管堆预留不使用内存大小,只由Mono使用。

Profiler内存重点关注优化项目:

1)ManagedHeap.UsedSize: 移动游戏建议不要超过20MB.

2)SerializedFile: 通过异步加载(LoadFromCache、WWW等)的时候留下的序列化文件,可监视是否被卸载.

3)WebStream: 通过异步WWW下载的资源文件在内存中的解压版本,比SerializedFile大几倍或几十倍,不过我们现在项目中展示没有。

4)Texture2D: 重点检查是否有重复资源和超大Memory是否需要压缩等.

5)AnimationClip: 重点检查是否有重复资源.

6)Mesh: 重点检查是否有重复资源.

Page7 学习感悟:

软件测试是用来描述一种用来促进鉴定软件的正确性、完整性、安全性和质量的过程。换句话说,软件测试是一种实际输出与预期输出之间的审核或者比较过程。软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对其是否能满足设计要求进行评估的过程。软件测试是对软件产品和阶段性工作成果进行质量检验,软件测试的目的是发现缺陷并且修正缺陷。

软件开发中出现错误或缺陷的机会越来越多,市场对软件质量重要性的认识逐渐增强。所以,软件测试在软件项目实施过程中的重要性日益突出。但是,现实情况是,与软件编程比较,软件测试的地位和作用,还没有真正受到重视,对于很多人(甚至是软件项目组的技术人员)还存在对软件测试的认识误区,这进一步影响了软件测试活动开展和真正提高软件测试质量。

在目前极限编程中有一个TDD测试驱动开发,具体来说就是测试在前,编码在后,这个主流的方法足以说明软件测试的重要性,人们一般认为,软件项目要经过以下几个阶段:需求分析,概要设计,详细设计,软件编码,软件测试,软件发布。据此,认为软件测试只是软件编码后的一个过程。这是不了解软件测试周期的错误认识。软件测试是一个系列过程活动,包括软件测试需求分析,测试计划设计,测试用例设计,执行测试。因此,软件测试贯穿于软件项目的整个生命过程。在软件项目的每一个阶段都要进行不同目的和内容的测试活动,以保证各个阶段的正确性。软件测试的对象不仅仅是软件代码,还包括软件需求文档和设计文档。软件开发与软件测试应该是交互进行的,例如,单元编码需要单元测试,模块组合阶段需要集成测试。如果等到软件编码结束后才进行测试,那么,测试的时间将会很短,测试的覆盖面将很不全面,测试的效果也将大打折扣。更严重的是如果此时发现了软件需求阶段或概要设计阶段的错误,如果要修复该类错误,将会耗费大量的时间和人力。

 

Guess you like

Origin www.cnblogs.com/Jewish/p/10961019.html