二、SpringBoot 配置 Junit Json

Junit

Junit.不用解释了吧,不知道的我只想说:出去。这篇我只简单介绍一下模拟request。后面陆续增加

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = BeautyApplication.class)
@WebIntegrationTest
public class TestSign  {
    RestTemplate restTemplate = new RestTemplate();//测试http请求的
    @Test
    public void testSignUp(){
        String url = "http://localhost:8080/sign/1";
        Map map = new HashMap<>();
        String result = restTemplate.getForObject(url, String.class, map);
        System.out.print(result+"=========");
    }
}

当然了,你要在maven里面配置上test

 <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.2.5.RELEASE</version>
        </dependency>

Json

在SpringBoot下,只要配置了JackJson,就会自己返回json了

<!-- Jackson JSON Mapper -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.0.2</version>
        </dependency>

github:https://github.com/HumorSmith/SprintBoot.git

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值