测试

这个作业属于哪个课程 2021春软件工程实践S班(福州大学)
这个作业要求在哪里 团队作业五-站立式会议+alpha冲刺
团队名称 饱满骑士
这个作业的目标 完成Alpha冲刺
其他参考文献

目录

测试工作安排

每个人完成自己的工作后,对自己完成的功能进行测试。全部测试无误后搭建测试场景,由大家一起测试。

测试工作

游戏的元素直接在场景中进行测试。由Unity项目构建游戏程序,并直接运行。
开始界面

选项界面

ESC界面

主角测试

冲刺

移动跳跃、攻击

爬墙

史莱姆

蜜蜂

树人

蘑菇精


认真跳跃

肉蛋充饥

肉球弹射

存档测试:
存档功能使用单元测试
针对基本类型,自定义类型的存取进行测试

using Microsoft.VisualStudio.TestTools.UnitTesting;
using ConsoleApp2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2.Tests
{
    [TestClass()]
    public class ProgramTests
    {
        private string fileName = "unitTest";
        [TestMethod()]
        public void BasicType()
        {
            GlobalData.SaveName = fileName;
            int currentHealth = 6;
            GlobalData.SetObject("currentHealth", currentHealth);
            int maxHealth = 10;
            GlobalData.SetObject("maxHealth", maxHealth);
            GlobalData.Save();

            GlobalData.SaveName = fileName;
            Assert.IsTrue(GlobalData.HasObject("currentHealth"));
            Assert.IsTrue(GlobalData.HasObject("maxHealth"));
            
            Assert.AreEqual(currentHealth, GlobalData.GetData<int>("currentHealth"));
            Assert.AreEqual(maxHealth, GlobalData.GetData<int>("maxHealth"));
        }
        [TestMethod()]
        public void PreDefinedClass()
        {
            GlobalData.SaveName = fileName;
            List<string> words = new List<string>();
            words.Add("the");
            words.Add("List");
            words.Add("<string>");
            words.Add("stores");
            words.Add("in");
            words.Add(fileName + ".save");
            GlobalData.SetObject("words", words);
            GlobalData.Save();

            GlobalData.SaveName = fileName;
            Assert.IsTrue(GlobalData.HasObject("words"));

            List<string> wordsTest = GlobalData.GetData<List<string>>("words");
            Assert.AreEqual(words.Count, wordsTest.Count);
            for (int i = 0; i < words.Count; i++)
                Assert.AreEqual(words[i], wordsTest[i]);
        }
        [TestMethod()]
        public void SelfDefinedClass()
        {
            GlobalData.SaveName = fileName;
            Program.PlayerInfo playerInfo = new Program.PlayerInfo
            {
                x = 1f,
                y = 2f,
                sceneName = "first scene",
                health = 10
            };
            GlobalData.SetObject("playerInfo", playerInfo);
            GlobalData.Save();

            GlobalData.SaveName = fileName;
            Assert.IsTrue(GlobalData.HasObject("playerInfo"));
            Program.PlayerInfo infoTest = GlobalData.GetData<Program.PlayerInfo>("playerInfo");
            Assert.AreEqual(playerInfo.ToString(), playerInfo.ToString());
        }
        [TestMethod()]
        public void SelfDefinedEnum()
        {
            GlobalData.SaveName = fileName;
            GlobalData.SetObject("jhon state", Program.NPCState.BeforeMission);
            GlobalData.Save();

            GlobalData.SaveName = fileName;
            Assert.IsTrue(GlobalData.HasObject("jhon state"));
        }
    }
}


生成的存档文件

<?xml version="1.0"?>
<SerializableDictionaryOfStringObject>
  <SerializableDictionary>
    <valueType>
      <XmlSerializableType>
        <XmlSerializableType>
          <string>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</string>
        </XmlSerializableType>
      </XmlSerializableType>
    </valueType>
    <key>
      <string>words</string>
    </key>
    <value>
      <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <string>the</string>
        <string>List</string>
        <string>&lt;string&gt;</string>
        <string>stores</string>
        <string>in</string>
        <string>test.save</string>
      </ArrayOfString>
    </value>
  </SerializableDictionary>
  <SerializableDictionary>
    <valueType>
      <XmlSerializableType>
        <XmlSerializableType>
          <string>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</string>
        </XmlSerializableType>
      </XmlSerializableType>
    </valueType>
    <key>
      <string>currentHealth</string>
    </key>
    <value>
      <int>6</int>
    </value>
  </SerializableDictionary>
  <SerializableDictionary>
    <valueType>
      <XmlSerializableType>
        <XmlSerializableType>
          <string>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</string>
        </XmlSerializableType>
      </XmlSerializableType>
    </valueType>
    <key>
      <string>maxHealth</string>
    </key>
    <value>
      <int>10</int>
    </value>
  </SerializableDictionary>
  <SerializableDictionary>
    <valueType>
      <XmlSerializableType>
        <XmlSerializableType>
          <string>ConsoleApp2.Program+PlayerInfo, ConsoleApp2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</string>
        </XmlSerializableType>
      </XmlSerializableType>
    </valueType>
    <key>
      <string>playerInfo</string>
    </key>
    <value>
      <PlayerInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <x>1</x>
        <y>2</y>
        <sceneName>first scene</sceneName>
        <health>10</health>
      </PlayerInfo>
    </value>
  </SerializableDictionary>
  <SerializableDictionary>
    <valueType>
      <XmlSerializableType>
        <XmlSerializableType>
          <string>ConsoleApp2.Program+NPCState, ConsoleApp2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</string>
        </XmlSerializableType>
      </XmlSerializableType>
    </valueType>
    <key>
      <string>jhon state</string>
    </key>
    <value>
      <NPCState>BeforeMission</NPCState>
    </value>
  </SerializableDictionary>
</SerializableDictionaryOfStringObject>

测试体会

对一般单机游戏如何进行测试不了解,选用了最直接的方式进行测试。测试过程中基本没遇到什么问题,主要是操作手感和游戏反馈不太好。思考一下没遇到问题的原因,玩家、怪物、环境之间的接口设计合理,只要每个人保证自己的部分能够按照预期运作,在整合时其他部分对他不会有影响;还有就是逻辑比较独立和简单,β冲刺要实现的怪物与环境或者玩家之间的逻辑会复杂一些,如果能继续保持良好的接口,那么接下来的编码也会比较顺利。

项目测试评述

是一个比较简单的测试,主要测试代码是否能够按照预期运作。事实上除了主角操作手感,都符合预期。测试方法有些过于简单,可能隐藏错误。在接下来的编码中,不应该默许这次的成果没有错误,时刻保持警惕。

posted @ 2021-05-14 22:55  饱满骑士开发组  阅读(109)  评论(5编辑  收藏  举报