@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*"})
@PrepareForTest({SecurityUtils.class})
@SpringBootTest
public class SysUserServiceImplTest {
@Autowired
PigxUser user;
@Before
public void setUp() {
PowerMockito.mockStatic(SecurityUtils.class);
Collection<? extends GrantedAuthority> authorities = new ArrayList<>();
user = new PigxUser(1, 1, 1, "用户名", "密码", true
, true, true, true, authorities);
Mockito.when(SecurityUtils.getUser()).thenReturn(user);//4.预设静态类返回值
}