zoukankan      html  css  js  c++  java
  • Junit单元测试

    Junit单元测试:
      测试分类:
        1. 黑盒测试:不需要写代码,给输入值,看程序是否能够输出期望的值。
        2. 白盒测试:需要写代码的。关注程序具体的执行流程。

      Junit使用:白盒测试
        步骤:
        1. 定义一个测试类(测试用例)
         建议:
          测试类名:被测试的类名Test  例:CalculatorTest
           包名:xxx.xxx.xx.test  例:com.fgy.test

        2. 定义测试方法:可以独立运行
         建议:
          方法名:test测试的方法名 testAdd()
          返回值:void
          参数列表:空参

        3. 给方法加@Test
        4. 导入junit依赖环境

        判定结果:
          红色:失败
          绿色:成功
        一般我们会使用断言操作来处理结果
           Assert.assertEquals(期望的结果,运算的结果);

        补充:
           @Before:
          修饰的方法会在测试方法之前被自动执行
          @After:
          修饰的方法会在测试方法执行之后自动被执行,即使有方法出现了异常,依然会执行

  • 相关阅读:
    OSCP Learning Notes Buffer Overflows(3)
    OSCP Learning Notes Buffer Overflows(5)
    OSCP Learning Notes Exploit(3)
    OSCP Learning Notes Exploit(4)
    OSCP Learning Notes Exploit(1)
    OSCP Learning Notes Netcat
    OSCP Learning Notes Buffer Overflows(4)
    OSCP Learning Notes Buffer Overflows(1)
    OSCP Learning Notes Exploit(2)
    C++格式化输出 Learner
  • 原文地址:https://www.cnblogs.com/roadlandscape/p/12180389.html
Copyright © 2011-2022 走看看