zoukankan      html  css  js  c++  java
  • Junit学习使用

     InputStream in;
        SqlSessionFactory factory;
        SqlSession session;
        UserDao userDao;
    
        @BeforeEach
        public void init() throws IOException {
            System.out.println("init....");
             in = Resources.getResourceAsStream("SqlMapConfig.xml");
             factory =new SqlSessionFactoryBuilder().build(in);
            session =factory.openSession();
            userDao = session.getMapper(UserDao.class);
    
        }
        /**
         * 测试查询所有
         */
        @Test
        public void testFindAll() throws IOException {
    
            //init();
            System.out.println("test....");
            List<User> users=userDao.findAll();
            for(User user :users)
            {
                System.out.println(user.toString());
            }
    
        }
    
    
        @AfterEach
        public  void close() throws IOException {
            System.out.println("close....");
            in.close();
            session.close();
    
        }
    

    一开始 before 和after都没有启动,不知道为什么,查了以后

    before 和after被beforeEach和afterEach代替了
  • 相关阅读:
    notebook笔记
    from __future__ import absolute_import
    GUI
    version_info
    函数参数
    None
    exec、eval
    os
    IGeometry接口
    IGeometry接口
  • 原文地址:https://www.cnblogs.com/gonT-iL-evoL-I/p/11720602.html
Copyright © 2011-2022 走看看