凌晨5点的测试

单元测试

一、单元测试

1.设计思路

  • 对方法进行测试,观察结果是否符合预期

2.部分单元测试代码

@Test
    public void testMathFactory() {
        //一年级
        GradeOneMath one = (GradeOneMath) MathExam.MathFactory(1);
        assertNotNull(one);
        assertTrue(one.getClass().equals(GradeOneMath.class));
        //二年级
        GradeTwoMath two = (GradeTwoMath) MathExam.MathFactory(2);
        assertNotNull(two);
        assertTrue(two.getClass().equals(GradeTwoMath.class));
        //三年级
        GradeThreeMath three = (GradeThreeMath) MathExam.MathFactory(3);
        assertNotNull(three);
        assertTrue(three.getClass().equals(GradeThreeMath.class));
    }

3.单元测试覆盖率

二、结构优化

1.UML图


2.运行流程图

3.各个模块的功能

  • 如上图

三、性能调优

1.结果截图

2.性能瓶颈

  • 性能达不到预期目标,运行时间过长

    3.优化方案

  • 整合代码中的大量重复代码,
  • 删除了将txt显示在屏幕的代码

四、总结

因为上次代码有点小问题,运算的方法写一起了,没有按年级拆开,导致这次测试的时候还要分类分包方便测试调用。这还不算惨==,因为每次测试都要调用所有运算方法,导致覆盖率相当的低,没办法了,来不及改了,现在已经凌晨5点了,一会还有四节移动互联的课==上完课就中午了。因为分了很多类,上传文件以后助教的程序识别不了那么多,只能把上次的代码稍微改了改提交上去了,感觉是凉透了,以后再也不敢了,下次一定好好写T-T,我真的知道错了。

猜你喜欢

转载自www.cnblogs.com/xzhp/p/9727366.html
今日推荐