springboot junit测试

1、springboot 测试

  pom文件配置信息:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
@RunWith(SpringRunner.class) //启动器
@SpringBootTest //测试
public class UserServiceTest {

@Autowired
UserService userService;

@Test
public void getUserName(){

System.out.println("userName:"+userService.getUserName());
}
}

以上是自学总结。有借鉴前辈帖子望见谅。不足之处请多多指教

猜你喜欢

转载自www.cnblogs.com/yixingzhou/p/11120247.html