camaraproject / Commonalities

Repository to describe, develop, document and test the common guidelines and assets for CAMARA APIs
Apache License 2.0
11 stars 25 forks source link

Test definitions - implementations guidelines and artifacts #94

Closed rartych closed 8 months ago

rartych commented 10 months ago

Problem description Delivery of API test cases and documentation is one of criteria in API Readiness Checklist. Each subproject needs to develop a Gherkin feature file for specified API. If subprojects also intend to add test implementations, an aligned single implementation that is agreed amongst all provider implementors could be added to the main subproject repo.

Possible evolution Definition of common guidelines and artifacts that would simplify development of test definition, documentation and implementation based on current experience in subprojects and within participating organizations.

Additional context As listed in https://github.com/camaraproject/SimSwap/issues/63 following projects already provide Gherkin feature files:

bigludo7 commented 9 months ago

Hello @rartych and team, How we can move forward on this? as I assume this is the only missing point in a lot of APIs to reach completion.

Looking in details of the Test Case already contributed and seems we are not far from one WG to another - need few alignements.

We need to agree on:

Definitely looking for consumer of these file to get their perspective. The less they have to do to use these files the better it will be.

mdomale commented 9 months ago

@bigludo7 Having one feature file per API or Resource ? or we keep this flexible and it's up to each project to manage this? (I prefer this later)

probably good for consistency to use all same pronoun (I or impersonal)

Scenario identifier. To trigger the discussion I propose '@'<(mandatory)name of the resource> <(mandatory)number XX><(optional)short detail> (like @check_simswap_01_Verify_Swap_True_Default_MaxAge)

Do we agree to have several when/then in one scenario ?

Providing either API literal request value (with example) or payload 'ready to use' (as in home device QoD) is fine?

bigludo7 commented 9 months ago

Thanks @mdomale for your comments and the url sources which are very helpful

To sump-up:

Expecting also comments from others companies involved in day to day CAMARA APIs crafting :)

shilpa-padgaonkar commented 9 months ago

Thanks @mdomale and @bigludo7 for your inputs and feedback. While we wait for few more days to get more feedback on the inputs, I would also propose to create a short Camara-API-Testing-Guidelines.md doc with the below content:

With this doc in place, we would not need to search for old issues regarding these discussed points when needed later, and would also allow the new Camara members to get an overview on the topic.

jlurien commented 9 months ago

Answering also to @bigludo7's questions. I think we are quite aligned with previous responses:

We also prefer one feature file per operationId.

Yes, we should agree on a common wording. The simpler the better.

As a example, to be refined:

Background: (assuming one feature file per operationId)
  Given:
    the environment 
    the path "path"
    the method "method"

Given:
  the (path param|query param|header) "name" is set to "value"
  the request body is set to
    """
    """
When:
  a "operationId" request is sent

Then:
  the status code is "X"
  the response value at "JSON-path" is "value"

We think it's good to include the operationId of the endpoint, along with some number to allow unique identification, and some description may also help, so a proposal could be:

@.[.] (separator here could be other than "." but we should choose one that cannot be part of the components)

It is preferable to have simple scenarios with just 1 when. While testing APIs, the structure is usually:

Given: request setup When: request is sent Then: response is validated

If some complex scenario requires that filling a request depends on the response from a previous one, we may allow several when

For the Given steps, in some cases we may give exact values for some parameters, for example providing wrong values to provoke an error, while in other cases the exact value cannot be known in advance and we have to ask the tester to fill the value. For example, in location-verification we should ask the tester to provide the well known latitude, longitude of a device to test a verificationResult=true scenario.