eclipse中如何跑spring boot的单元测试


1、首先引入对应的pom依赖

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-configuration-processor</artifactId>
   <optional>true</optional>
</dependency>
1
2
3
4
5
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:spring/bbs*.xml"})
public class AbstractTest {

}

public class AdServiceTest extends AbstractTest {

    @Autowired
    AdService adService;

    @Test
    public void test() {
        AdParam adParam = new AdParam();
        adParam.setAdPositionId(16005);
        adParam.setNum(20);
        List<AdModel> adModels = adService.queryAdList(adParam);
        System.out.println(JSON.toJSONString(adModels));
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

参考资料 :

http://412887952-qq-com.iteye.com/blog/2307104

联系我

添加@pdai微信

PS:添加时请备注Java全栈,谢谢!