美文网首页
Android测试汇总

Android测试汇总

作者: Small_Cake | 来源:发表于2018-08-14 14:17 被阅读37次

    原文链接:https://www.jianshu.com/p/0db8381ca480

    参考:https://www.jianshu.com/p/37207d56331f

    Android测试基于JUnit,创建项目后,AndroidStudio默认会帮我们创建两个测试类:

    默认测试类
    上面ExampleUnitTest用于测试不需要Android相关组件的方法,而ExampleInstrumentedTest则是测试一些需要基于Android组件的方法,例如需要页面,数据,服务什么的!
    1.ExampleUnitTest:

    例如:你只想测试一下两个数的计算是否正确,可以打印计算后的结果:

    public class ExampleUnitTest {
        @Test
        public void addition_isCorrect() throws Exception {
            assertEquals(4, 2 + 2);
        }
    
        @Test
        public void computer() throws Exception {
            double a = 1.89d;
            double b = 0.9d;
            System.out.print(ComputationUtil.mul(a, b));
        }
    }
    
    测试结果

    相关文章

      网友评论

          本文标题:Android测试汇总

          本文链接:https://www.haomeiwen.com/subject/ohhyvftx.html