J'essaie d'apprendre comment créer un simple fichier de définition d'étape de travail pour mon fichier de fonction de cornichon en utilisant le module nodejs apickli. Si j'essaye de faire une preuve de concept très simple en me connectant à l'API GitHub. Voici l'appel API utilisant curl.J'ai du mal à obtenir une simple suite de tests BDD pour une API utilisant gherkin apickli
curl -i https://api.github.com/users/marktyers/orgs
Cela renvoie un code de réponse de 200
J'ai installé cucumber
et apickli
:
npm install --save-dev cucumber apickli
Voici ma structure de fichier:
├── index.js
├── package.json
└── test
└── features
├── step_definitions
│ └── myapi.js
└── test.feature
Voici mon test.feature
fichier:
Feature:
As a novice I want to test my BDD framework.
Scenario: Retrieving an empty list should return a 200 code.
Given I set Content-Type header to application-json
When I GET https://api.github.com/users/marktyers/orgs
Then response code should be 200
Voici mon fichier myapi.js
.
'use strict'
const apickli = require('apickli')
module.exports = function() {
// cleanup before every scenario
this.Before(function(scenario, callback) {
this.apickli = new apickli.Apickli('http', 'httpbin.org')
callback()
})
Quand je lance le test de fonctionnalité que je reçois:
Feature:
As a novice I want to test my BDD framework.
Scenario: Retrieving an empty list should return a 200 code.
? Given I set Content-Type header to application-json
? When I GET https://api.github.com/users/marktyers/orgs
? Then response code should be 200
Warnings:
1) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: Given I set Content-Type header to application-json - test/features/todo.feature:6
Message:
Undefined. Implement with the following snippet:
Given('I set Content-Type header to application-json', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
2) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: When I GET https://api.github.com/users/marktyers/orgs - test/features/todo.feature:7
Message:
Undefined. Implement with the following snippet:
When('I GET https://api.github.com/users/marktyers/orgs', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
3) Scenario: Retrieving an empty list should return a 200 code. - test/features/todo.feature:5
Step: Then response code should be 200 - test/features/todo.feature:8
Message:
Undefined. Implement with the following snippet:
Then('response code should be {int}', function (int, callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
Je sais que je dois inclure des définitions étape supplémentaires, mais où ils doivent aller et ce qui devrait aller en eux?
Merci Matt. Y a-t-il une documentation pour la dernière version s'il vous plaît? –
Non désolé malheureusement, il est assez difficile de trouver une documentation solide sur la dernière version pour l'un ou l'autre. J'ai seulement découvert cucumberjs de leur documentation de sortie et pour apickli il ne mentionne pas c'est seulement compatible avec [email protected], le seul cadeau est la façon dont les étapes sont mises en œuvre. Juste quelque chose que nous devons nous habituer à la terre JS/Node par opposition à Java etc., tout est si mal documenté ... – matt