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

    1、非注解

    public class Test {
        @org.junit.Test
        public void  testPrice() {
            
        ClassPathXmlApplicationContext beans = new ClassPathXmlApplicationContext(new String[]{"spring.xml","spring-mybatis.xml"} );
            IStationService stationService = (IStationService) beans.getBean("stationService");
            Double s=stationService.calcuStationEndPrice("k596", "砀山", "芜湖");
            System.out.println(s);
        }
    }

    2、注解

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations={"classpath:spring.xml","classpath:spring-mybatis.xml"})
    public class Test {
        @Autowired
        private IStationService stationService;
        @org.junit.Test
        public void  testPrice() {
            Double s=stationService.calcuStationEndPrice("k596", "砀山", "芜湖");
            System.out.println(s);
        }
    }

    这里更推荐使用注解的方法。

  • 相关阅读:
    前端开发Code Review内容【vue记录】
    Blue Jeans
    Arbitrage
    Common Subsequence
    Palindrome
    Stockbroker Grapevine
    Asteroids
    Frogger
    All in All
    Highways
  • 原文地址:https://www.cnblogs.com/laoyeye/p/6505672.html
Copyright © 2011-2022 走看看