earloc / postomate

A library to automate and orchestrate requests out of a postman-collection with .net
MIT License
2 stars 0 forks source link

Showcase best-practices when authoring postman-collections #16

Open earloc opened 3 years ago

earloc commented 3 years ago

When authoring parameterizable postman-collections, we end up in collections containing requests that for themselfs might not be executable anymore.

E.g.: the following request is not executable without specifying values for the given variables (like via an environment?!): image

We need to ensure that Postman knows about the two variables firstName and surname.

When automating these requests, this is quite straight forward, by leveraging one of the IVariableContext-implementations:

variables = new ImmutableVariableContext(new {
    baseUrl = api.BaseAddress?.ToString().Trim('/') ?? "http://localhost:5042"
});

and later:

 var createArthurRequest = folder.FindRaw("PostPerson", variables.Enrich(new {
    firstName = "Arthur",
    surname = "Dent"
}));

However, we lose tha ability to just fire the request out of Postman itself, without finding a good way to actually specify values for the variables.

The current way is to add a pre-request script, which fills the variables with appropriate values prior sending the request. Is there another, better way? Especially to ensure completeness (that is, ensuring that every possible variable actually gets a meaningful value?)... image

Regardless of the above question, this approach should be documented in the repo´s readme.