package me.zhengjie; import me.zhengjie.utils.SecurityUtils; 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(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class SpringApplicationTest { /** * 获取当前的用户信息 */ @Test public void testGetName(){ System.out.println(SecurityUtils.getCurrentUsername()); } }