xrysanthos / apispots-bdd

Adds a BDD layer to API automated testing
MIT License
7 stars 3 forks source link

Cannot execute test we invoked by rest service but workd on portal #4

Closed paragparandkar closed 8 years ago

paragparandkar commented 8 years ago
  1. When is execute test to check weather using portal http://192.168.1.92:3000/docs we get right output but when executed using curl it as follows -

parag@parag1:~/dev/test$ curl -i -F file=@test2.feature -F tags=%40dev http://localhost:3000/tests/run

HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request content-type: application/json; charset=utf-8 cache-control: no-cache content-length: 160 Date: Sat, 11 Jun 2016 16:35:04 GMT Connection: keep-alive

{"statusCode":400,"error":"Bad Request","message":"child \"format\" fails becaus e [\"format\" is required]","validation":{"source":"payload","keys":["format"]}}

the following feature file (taken from project website) was used-

Feature: OpenWeatherMap API - Current weather data

As a client of the OpenWeatherMap API I want to run tests In order to validate 'Current weather data' operations

Background: Given a "REST" API definition at "http://api.openweathermap.org/data/2.5"

Scenario: Get current weather data for one location and by city name

Given endpoint "/weather" and method "get"
And request query param "q" equals "London,UK"
And request type "application/json"
When the request is executed
Then response status is "ok"

response on website I want to run tests In order to validate 'Current weather data' operations

Scenario: Get current weather data for one location and by city name Given a "REST" API definition at "http://api.openweathermap.org/data/2.5" Given endpoint "/weather" and method "get" And request query param "q" equals "London,UK" And request type "application/json" When the request is executed Then response status is "ok"

1 scenario (1 passed) 6 steps (6 passed) 0m00.047s

Bute

xrysanthos commented 8 years ago

Hi @paragparandkar. The error message is returned from the Swagger layer as the request is missing the required parameter format. This has been introduced in the latest version. I'll switch the param to optional, but in the meantime if you add it to your curl request you should be good to go.

curl -i -F file=@test2.feature -F format=pretty -F tags=%40dev http://localhost:3000/tests/run

paragparandkar commented 8 years ago

Hi Chris

Now I get

parag@parag1:~/dev/test$ curl -i -F file=@test1.feature -F format=pretty -F tags=%40dev http://localhost:3000/tests/run HTTP/1.1 100 Continue curl: (52) Empty reply from server

and logs show following errors- TypeError: tagGroupStrings.map is not a function at Object.module.exports._run as run at Object.module.exports._runTest as runTest at server.route.config.handler (/app/rest/routes.js:64:24) at Object.internals.handler (/app/node_modules/hapi/lib/handler.js:96:36) at request._protect.run (/app/node_modules/hapi/lib/handler.js:30:23) at internals.Protect.run (/app/node_modules/hapi/lib/protect.js:64:5)

please guide am I missing anything

Regards Parag

On Sun, Jun 12, 2016 at 9:13 AM, Chris Spiliotopoulos < notifications@github.com> wrote:

Hi @paragparandkar https://github.com/paragparandkar. The error message is returned from the Swagger layer as the request is missing the required parameter format. This has been introduced in the latest version. I'll switch the param to optional, but in the meantime if you add it to your curl request you should be good to go.

curl -i -F file=@test2.feature -F format=pretty -F tags=%40dev http://localhost:3000/tests/run

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chefArchitect/apispots-testing-bdd/issues/4#issuecomment-225416307, or mute the thread https://github.com/notifications/unsubscribe/AJNnBtNAF5KCIW5hLuSYOdq0Ht4GQmlvks5qK7-fgaJpZM4Izl5I .

xrysanthos commented 8 years ago

Hi @paragparandkar. Sorry for the hassle :( Had to refactor the code for making it compatible with the latest Cucumber v1.0.0 and missed a point regarding tags. Please pull the latest Docker image and you should be ok.

Also, I just found out that the OpenWeatherMap API (used in the example) now requires an API key to be created prior to any integration, so make sure you read the updated tutorial http://apispots.com/projects/bdd/a-first-example/