作业3-单元测试

一、单元测试


1.设计思路

  • 固定返回值的函数通过对比与预期结果是否一致进行测试判断

  • 随机返回值的函数通过对比是否在预期结果范围内进行测试判断

  • 调度场算法通过函数异常中转进行测试判断

2.部分代码

import static org.junit.Assert.*;

import org.junit.Test;

public class ParameterTest {

	@Test
	// 测试 -n 数量 -Grade 年级
	public void DealDataOne() {
		String[] args = {"-n","10","-Grade","3"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args));
	}
	@Test
	// 测试 -Grade 年级 -n 数量
	public void DealDataTwo() {
		String[] args = {"-Grade","10","-n","3"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试 n 错误
	public void DealDataThree() {
		String[] args = {"n","10","-Grade","3"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试参数数量错误
	public void DealDataFour() {
		String[] args = {"-n","10","-Grade"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试 Grade 错误
	public void DealDataFive() {
		String[] args = {"-n","10","-Grade","10"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试格式错误
	public void DealDataSix() {
		String[] args = {"n","10","-Grade","3"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试格式错误
	public void DealDataSeven() {
		String[] args = {"-Grade","3","n","10"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试不为纯数字
	public void DealDataEight() {
		String[] args = {"-Grade","3AA","-n","10"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	// 测试不为纯数字
	public void DealDataNine() {
		String[] args = {"-Grade","3","-n","AAA"};
		//测试boolean
		assertTrue(new Parameter(args).DealData(args) == false);
	}
	@Test
	public void GetNumber() {
		String[] args = {"-n","10","-Grade","3"};
		//测试boolean,long,int等
		assertEquals(10, new Parameter(args).GetNumber());
	}
	@Test
	public void GetGradeOne() {
		String[] args = {"-n","10","-Grade","3"};
		//测试boolean,long,int等
		assertEquals(3, new Parameter(args).GetGrade());
	}
	@Test
	public void GetGradeTwo() {
		String[] args = {"-n","10","-Grade","4"};
		//测试boolean,long,int等
		assertEquals(0, new Parameter(args).GetGrade());
	}
	@Test
	// 测试纯数字
	public void isNumOne() {
		String[] args = {"-n","10","-Grade","3"};
		assertTrue(new Parameter(args).isNum("123"));
	}
	@Test
	// 测试非纯数字
	public void isNumTwo() {
		String[] args = {"-n","10","-Grade","3"};
		assertTrue(new Parameter(args).isNum("777A") == false);
	}
}

3.测试覆盖率

![avatar][Cover]

[Cover]: data:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0wAAABrCAIAAADLvpXzAAAgAElEQVR4Ae2dDXBdxXn398qOjW3yYoqglFAGg67DOGII4KTu1TAUMxlHUprKNKN0UjouMb1qM0ol6qrl7atAS01DqgakRpMZaTAZQWhSdwCBa90K2/E774xuTeukMAiN6yunGBvChwk2YAujj/s+u3s+9py75+N+6Oh+/M/c0T1nP57d/e3Zvc959tmjWDabZThAAAQiIfDGG29cccUVkRRVGYUASDT9BM7+nL/3ve9985vfzE3jFZ6bsgZDcFNF0+lFcq6LppYoBQRAAARAAATKk4BWw6OqeoWXZytQKxDIJeCn5KU6YrGmgencTAgBARAAARDQEJgeaIrFOlKaGASVjsDi/zZVdj8uPp/S9WVBkqq+gQVR0WfiSp64nWPqgTlKTwuhILBkBPi0Zh01OUIrmwB+lvyHjvEz5GFWkH1v3vbTRyf9hS1ibCX041LyyVUn5Kzl0bEl7qlK6J0SNzlQnGnJS/RnyDvPPIaaAzNGmYB3nDm8oywXZYFAWRAQ82YLGzPHZzbbNhrNnFkWzadK1DyB2pgDE4lEevfe3MWj6YGdwxRn3Y0NXRPZ7ERXgxVQMSeL1I8usUvJR5QtZqqxJGO2YhGuu1wNibhfF6n0RRIbFo6p5IVNj3QgAALREkh1xLsZPYSpj17NQ+HmzGhrulilgcBikS0z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AIBKqaQNVoaVXdS1E1TrxOMGMYPaMqFOWAAAgUT6DsB28JlLziKUECCIAACNQuAdrzDGeS2u1+tLySCZT94C1240Uldw7qDgIgAAIgAAIgAAJVSwBKXtV2LRoGAiAAAiAAAiBQywRiJ06cqOX2o+0gAAIgAAIgAAIgUJUESrC7tiq5oFEgsBgEsJnURRVAXEAW6RK7axcJbC2Lxe7aaHq/yEkSy7XRdBNKAQEQAAEQAAEQAIFICUDJixQ3CgMBEAABEAABEACBaAhAyYuGM0oBARAAARAAARAAgUgJQMmLFDcKAwEQAAEQAAEQAIFoCEDJi4YzSgEBEAABEAABEACBSAlAyYsUNwoDARAAARAAARAAgWgIQMmLhjNKAQEQAAEQAAEQAIFICUDJixQ3CgMBEAABEAABEACBaAhAyYuGM0oBARAAARAAARAAgUgJQMmLFDcKAwEQAAEQAAEQAIFoCEDJi4YzSgEBEAABEAABEACBSAlAyYsUNwoDARAAARAAARAAgWgIQMmLhjNKAQEQAAEQAAEQAIFICUDJixQ3CgMBEAABEAABEACBaAhAyYuGM0oBARAAARAAARAAgUgJQMmLFDcKAwEQAAEQAAEQAIFoCPx/w0cuMjUJJicAAAAASUVORK5CYII=

二、结构优化


1.UML类图

avatar

2.运行流程图

avatar

3.代码重构

(1)重构部分

  • 题目生成
  • 参数处理

(2)重构原因

  • 便于单元测试
  • 代码模块化
  • 增加代码耦合度

(3)当前模块功能

  • MathExam为主类,用于接收参数
  • File为文件类,用于写出文件
  • Parameter为参数处理类,用于检查接收到的参数是否合格并进行处理
  • ShuntingYard为调度场算法类,用于实现调度场算法,计算表达式结果
  • TaskMake为题目生成类,用于随机生成题目

三、性能调优


1.优化前效能分析

avatar

2.性能瓶颈

  • String.toArray()方法处理效率较低

3.解决方案

  • 使用String.charAt(index)方法替代

4.优化后效能分析

avatar

四、总结


  • 同类功能的函数应该封装到同一个类中

  • 多次使用的方法封装为函数,减少代码量,且代码美观

posted @ 2018-09-29 23:20  IMRIVER  阅读(553)  评论(4编辑  收藏  举报