RunWith

package com.example.demo;

import com.example.model.User;
 
import com.example.util.SpringUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
 
@RunWith(SpringRunner.class)
@SpringBootTest
JunittestmoduleApplicationTests
public class JunittestmoduleApplicationTests {
@Test
    public void contextLoads() {
    
    User user = (User)SpringUtil.getBean("user");
    
    System.out.println(user.toString());
  }
}
posted @ 2022-12-15 16:17  cnetsa  阅读(148)  评论(0编辑  收藏  举报