package com.sf.service;

import com.sf.config.SpringConfig;
import com.sf.entity.Tea;
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;

/**
 * @author WanJl
 * @version 1.0
 * @title TeaServiceTest
 * @description
 * @create 2025/11/30
 */
//是spring-test依赖库提供的，使用spring整合junit专用的类加载器
@RunWith(SpringJUnit4ClassRunner.class)
//加载spring的核心配置类，相当于在main方法中使用的加载核心配置类:
//        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
@ContextConfiguration(classes = {SpringConfig.class})
public class TeaServiceTest {
    @Autowired
    TeaService teaService;

    @Test
    public void testQueryAll() {
        List<Tea> teaList = teaService.queryAll();
        for (Tea tea : teaList){
            System.out.println(tea);
        }
    }
}
