千寻

道路很长, 开始了就别停下!

0%

Springboot单元测试

eclipse中如何跑springboot的单元测试

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

1
2
3
4
5
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@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));
}
}

参考资料:

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