Matching the request body is also a requirement in many situations. Session that consists of lowercase alphanumerics only: Of predicates, so that it’s possible to match loosely or precisely, depending on your needs.įor instance, you could match a request with a query parameter of searchĮxactly equalling pyjamas, an Accept header containing json and a cookie named MockLab supports matching of all of these attributes. So a request sent with any combination of these values will always be matched provided Postman doesn’t use query parameters, headers or cookies in its matching process, Regex expressions that will match anything, or choose to constrain the range of valid This gives some additional control over named parameters - you can use very loose MockLab also supports loose matching of URL paths, but via the use of regular expressions In your URL path you can specify a parameter name and this will be treated as a wildard, so any value will be accepted: Postman supports a degree of request matching flexibility above simple method + URL when we want to returnĪ response regardless of the user ID passed in the URL path. Sometimes it’s also necessary to match more loosely e.g. It’s not uncommon to need to match headers, cookies or request body elements. This is often as simple as checking that the HTTP method and URL are exactly equal but Select the correct response for the incoming request based on a set of criteria. In MockLab, stubs are added directly from within a mock API’s Stubs page:Īn essential component of mocking is request matching. Adding a new example to a request in a collection will automatically In Postman, examples in a collection are used directly to configure responses in MockLab also permits you to optionally choose a hostname of your own, so you can MockLab will also generate a unique domain name, using a short hash for the hostname e.g. Postman will generate a unique domain name for a mock server using a UUID for the To use a mock server/API in either product, a unique base URL is needed. In MockLab you can create a new mock API via the “+ Mock API” button on the top bar: In Postman you create a mock server either via the context menu for a collection, or from the Mock Servers tab: With both products you need to sign-up/log into a user account in order to create a mock API/server. Responses that contain random values, variables or request data. Specification of a request to be matched, paired with the response to be returned. Products’ terms for each major concept: MockLabĪ container for stubs/examples. The concepts underlying Postman’s and MockLab’s mocking capabilities are very similar,īut some naming and terminology differs. ThisĪrticle compares Postman’s capabilities and approach to API mocking with MockLab’s,Įxamining the relative strengths and best use of each. If you’re involved in developing or testing APIs it’s highly likely you’ve used itĪ feature of Postman is “mock servers”, which allows mock APIs to be generated fromįrom Collections (Postman’s main data model - sets of request and response examples). Postman is indisputably the dominant HTTP testing tool on the market today, and
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |