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());
}
}

以上是自学总结。有借鉴前辈帖子望见谅。不足之处请多多指教
posted @ 2019-07-02 13:58  易行舟  阅读(213)  评论(0编辑  收藏  举报