zoukankan      html  css  js  c++  java
  • JUnit测试

    简介

    JUnit 是用于编写和运行可重复的自动化测试的开源测试框架。

    • 断言测试

    [实操]hello-JUnit

    1. 依赖
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    
    1. 建包

    1. 编写测试类
    public class UserServiceTest {
    
        private UserService userService;
    
        @Before
        public void before(){
            System.out.println("初始化数据库连接");
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-context.xml");
            userService = (UserService) applicationContext.getBean("userService");
        }
    
        @Test
        public void testSayHi(){
            userService.sayHi();
        }
    
        @After
        public void after(){
            System.out.println("关闭数据库连接");
        }
    }
    

    注解

    • @Test
    • @Before
    • @BeforeClass
    • @After
    • @AfterClass
    • @Ignore

    断言

    F2 定位下一个有问题的地点

  • 相关阅读:
    redhat 5 中文乱码
    生成树
    交换机端口模式
    链路聚合
    AP注册
    信息收集
    Python 25 Django跨域请求
    Python 24 Django之csrf中间件
    Python 23 Django基础
    Python 21 Flask(三)第三方组件
  • 原文地址:https://www.cnblogs.com/hhhqqq/p/12582859.html
Copyright © 2011-2022 走看看