【发布时间】:2021-02-22 23:04:48
【问题描述】:
我有一个简单的 REST API,它允许在给定端点中发布资源,并且我想验证响应标头是否设置正确。我定义了以下功能,在数据库中插入一堆用户:
Scenario Outline: Creating a bunch of new users when the database is empty
Given header Content-Type = 'application/json'
And request __row
When method post
Then status 201
* match header Content-Type == 'application/json'
* match header Location == 'http://localhost:8080/users/'+response.id
Examples:
| users |
用户已正确插入,在控制台中我可以看到以下响应标头:
1 < 201
1 < Connection: keep-alive
1 < Content-Type: application/json
1 < Date: Mon, 22 Feb 2021 14:06:31 GMT
1 < Keep-Alive: timeout=60
1 < Location: http://localhost:8080/users/user1@test.com
1 < Transfer-Encoding: chunked
但每次我尝试运行此测试时,都会得到相同的响应:
path: $['Content-Type'][0], actual: null, expected: 'application/json', reason: actual json-path does not exist
【问题讨论】:
-
你能不能试试新的 RC 版本,这应该会更好:github.com/intuit/karate/wiki/1.0-upgrade-guide