Follow

Creating a New API Model

Starting a New Functional API Test

The first step in creating functional API Tests is to create an API model in API Test Maker that you use to generate the tests.

Once you are logged in to BlazeMeter, click Create Test at the top of the navigation bar, and then click API Test Maker. Be sure to create the test in the relevant Project.

Screen_Shot_2017_06_04_at_6.41.37_PM.png

APITestMaker.png

Clicking API Test Maker opens a new tab and displays the choices of Swagger and Manual. If you don't see it yet, click Create API Tests in the top navigation bar.

CreateAPITests.png

A few things to know as you create your model (and before you create tests):

  • Authentication
    If you are testing an API that requires some form of authentication, it is important to understand that the authentication is assigned at the time of test creation. That means you should define the authentication for your tests prior to creating the tests. If you define the authentication after creating your tests, you have to regenerate the tests for them to use the defined authentication. For more information, see Managing Authentication in API Test Maker.
  • Text Execution Location
    You can also set a location for the execution of your tests. This includes predefined geographic locations as well as any Private Locations that you defined in BlazeMeter to test applications behind a firewall. Your selected location is applied to the tests at the time of creation. You should select a location prior to creating your tests from the Test Execution Location list at the top of the Edit API Tests page. If you don't select a location, BlazeMeter automatically selects a default location for you at the time of execution. If you are using a Private Location, note that you can create auto generated and manual tests, but the Quick Test feature is disabled. For more information about setting up on-premise testing for a private location, see Private Locations and Install a New On-Premise Agent.
  • SQL Injection
    SQL injection tests check your API for vulnerability from SQL injection attacks where a partial or complete SQL query is injected along with an API request. You should define the details for your SQL injection tests prior to creating auto generated tests. If you define these details after creating your tests, you have to regenerate the tests for your set of tests to include the SQL injection test. For more information about creating this type of test, see Creating SQL Injection Tests.

Importing a Swagger Specification

You can upload any valid API specification in either a .json or .yaml format to use as the basis of your API tests. The file size for each upload is limited to 500kb.

Note: There is a known issue where leaving your browser inactive for an extended period of time can, in rare instances, prevent the successful upload of a Swagger specification. If you are having an issue uploading a Swagger spec, try either clearing your browser cache or switching your browser to incognito mode.

  1. Click Create API Tests in the menu bar at the top of the page.
    The Create API Tests page opens.
  2. Drag the file that you want to upload into the Swagger area. You can also click this area to browse for files in a specific location.
    Your file displays in the Swagger section of the page.
  3. Click Next.
    The Edit API Tests page opens. This page shows the API model that was created, based on the uploaded specification. Within the model, you can view each of the resources included in the API.
  4. Click a resource name to view the operations under that resource.
  5. Click an operation name to view the details for that operation in the right side of the page.
    For more information about modifying your API model, see Modifying the API Test Maker Model.
    SwaggerModel.png

The following video provides a brief introduction to importing a Swagger specification.

Creating an API Model Manually

If you don't have an existing specification for your API, you can also create a model manually by defining each of the resources and operations in your API.

  1. Click Create API Tests in the menu bar at the top of the page.
    The Create API Tests page opens.
  2. Click the Manual area.
    The Create Manual API Model window opens.
    ManualModel01.png
  3. Enter a base URL (without paths) and model name in the Base URL and Model Name fields.
  4. Click Next.
    The Edit API Tests page opens. Your base URL displays at the top of the page.
  5. Select the type of operation that you want to add (GET, POST, PUT, DELETE, or PATCH).
    ManualModel02.png
  6. Type the resource path in the Enter resource path field.
    • Path parameters are defined as part of your resource path. They are indicated with {}. You can change reference values and constraints for path parameters in the Parameters tab, but you cannot add or remove them. By default, path parameters are created with a type of String, and the Required constraint is set to True.
      For example, /pet/{petId} creates a path parameter of petId.
    • Rather than creating query parameters one at a time in the Parameters tab, you can include them here in your resource path.
      For example, /user/login?username=admin&password=password creates a resource of /user/login with two query parameters: username with a reference value of admin, and password with a reference value of password.
    • The base URL displays at the top of the left pane. You do not need to repeat the base URL. Just enter the relative path. For example, type /pet instead of typing http://petstore.jsonpetstore.swagger.io/pet.
  7. Click the plus (+) sign to add a new resource to the resource list with the selected operation.
  8. Continue to add more operations and resource paths until your model is completely defined.
    You can only have one operation of each type (GET, POST, PUT, and so on) for each resource path. If the resource path that you enter already exists for the selected operation, an error message appears.
  9. (Optional) On the Summary tab, enter a description for the operation.
    This description displays in the list of models in the Manage API Tests page to help you identify it.

For more information about adding additional elements to an operation, such as parameters, reference values, and constraints, see Modifying the API Test Maker Model

The following video provides a brief introduction to manually creating an API model.

Have more questions? Submit a request

0 Comments

Article is closed for comments.