欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring 单元测试之Service 层

程序员文章站 2022-03-02 15:38:37
...
import java.util.List;

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 com.saiku.admin.sys.service.AdminService;
import com.saiku.pojo.SjAdmin;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class AdminTestService {

    @Autowired
    private AdminService adminService;

    @Test
    public void test_1(){

     List<SjAdmin> sjAdmins = adminService.findAll();

//        System.out.println("数据:"+ );

        if(null != sjAdmins && sjAdmins.size()>0){
            for(int i=0;i<sjAdmins.size();i++){
                System.out.println("ID号:"+sjAdmins.get(i).getAdminid());
            }
        }
    }
}