使用phpunit laravel 5.2测试API

使用phpunit laravel 5.2测试API,php,json,laravel-5,laravel-5.2,phpunit,Php,Json,Laravel 5,Laravel 5.2,Phpunit,因此,我在/test目录中创建了一个测试类 在testExample函数中,我将输入和输出JSON字符串存储到变量中 使用将输入和输出字符串转换为数组 json_解码(inputstring,true);json_解码(outputstring,true) 我已经使用以下方法来测试这个API $this->json('POST', 'api/v1/tagging', $input, ['Content-Type' => 'application/json'])

因此,我在/test目录中创建了一个测试类 在testExample函数中,我将输入和输出JSON字符串存储到变量中

使用将输入和输出字符串转换为数组 json_解码(inputstring,true);json_解码(outputstring,true)

我已经使用以下方法来测试这个API

$this->json('POST', 'api/v1/tagging', $input, ['Content-Type' => 'application/json'])
            ->seeJson([
                'conversion_specs' => ["post_engagement"],
            ]);
其中转换规格:
[“参与后”]
是输出json的一部分

我怎么能断言它,它在点击后打印了太多的数据
/vendor/bin/phpunit
命令


我认为它出了问题,谁能帮我检查一个具有预期值的API。

使用postman,您可以测试您的API。yes@Abdullah Al-Shakib我已经在postman上进行了测试,并正在使用laravel 5.2中的phpunit编写测试用例。你能告诉我热测试一个API,我有输入和输出JSON字符串(我从postman那里获取的)只需要使用phpunit测试它,您可以发布您在phpunit中尝试过的内容吗?也许我没有遵循您的要求,但听起来您只是想将预期的json与返回的内容进行比较,
$this->assertEquals($expected,$actual)我正在点击API,它给了我特定的JSON响应,我想用phpunit测试它,所以我在laravel 5.2文档中得到了$this->JSON()方法,它点击post请求,对吗。。。。如果是,请告诉我如何使用seeJson()