Maven,Junit使用方法

1.maven是什么?

 是一个项目构建和管理的工具,提供了帮助管理,文档,报告,依赖,scms,发布,分发的方法

 通俗讲就是管理jar包的

2.maven怎么实现这些功能的?

   maven在你的电脑上有个仓库(文件夹),专门存放项目需要的jar包

  如果本地仓库(文件夹)没有需要的jar包,那么maven会去网上自动下载jar包到你的本地仓库(文件夹)

3.Junit是干嘛的?

  用来做单元测试的

4.Junit怎么用?

   将Junit的jar包导入项目

   在需要测试的代码块前面加上@Test,好处就是不需要new对象也能测试,很方便

   被测试的代码块:

    

 SqlSession mySession=MybatisUtils.getSqlSessionFacory().openSession(true); //openSession设置为true就是自动提交事务	
    	 List<Student> list=mySession.selectList("Mapper.studentMapper.getAllStudent");
    	System.out.println(list);
    	 mySession.close();  
   用个方法包装一下,然后前面加上@Test,如下:  
  @Test
	public void testtt()
	{
      SqlSession mySession=MybatisUtils.getSqlSessionFacory().openSession(true); //openSession设置为true就是自动提交事务	
    	 List<Student> list=mySession.selectList("Mapper.studentMapper.getAllStudent");
    	System.out.println(list);
    	 mySession.close();  
	}
  然后点击run,运行Junit就可以了  

   

猜你喜欢

转载自542255641.iteye.com/blog/2253460