ssm框架下测试接口

1.首先导入pom依赖

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
import com.zw.dao.Dao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)//指定Spring的运行器来集成。
//指定配置文件的位置,注意这里路径的写法 classpath指的是编译之后文件夹classes下,冒号后面没有/
@ContextConfiguration("classpath:spring/spring-dao.xml")
public class test3{
    /**
     * 自己写的main方法测试,这个dao是无法自动导入的,因为需要启动tomcat容器来实现javaBean的管理与注入。
     * JUnit4解决了这个问题,在不启动tomcat容器的情况下来实现javaBean的注入,方便来测试接口。
     */
    @Autowired
    Dao dao;
    @Test
    public void test(){
        System.out.println(dao);
        List<String> list=dao.selectAllSystemcode("2020-5-6 10:00:00","2020-6-10 10:00:00");
        System.out.println(list);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值