Using the toolkit CLI to execute API tests

The IBM® API Connect developer toolkit provides CLI commands for automated API behavior testing.

About this task

Use CLI commands to execute API tests.
Note: In order to execute an API for testing purpose, you must make it online. To make the API online and auto-publish your API document, set the Auto-publish toggle on the Preferences page to On position. For more information, see Activating an API.

Procedure

  1. Install the toolkit: Setting up the toolkit for V10 Reserved.
  2. Open Terminal.
  3. Create a YAML file to define your tests. For more information, see API development and management commands.
  4. Run the CLI with the following syntax to execute the tests:
    apic test yaml-files
    
    Where, yaml-files specifies the location of the YAML file. For example, apic test test1.yaml
    • For executing tests with certificate checks disabled, run the CLI using the --insecureSkipVerify flag. For this, use the following syntax:
      apic test yaml-files
       --insecureSkipVerify
      
      Where, yaml-files is the location of the YAML file. For example, apic test test1.yaml.
    • If the CA certificate is not available in the system's keystore, its location can be specified with --certPath flag. For this, run the CLI with the following syntax:
      apic test yaml-files
       --certPath=location of certs folder
      
      Where, yaml-files is the location of the YAML file. For example, apic test test1.yaml. location of certs folder specifies the location of the CA certificate.
    • For executing tests with mTLS enabled, run the CLI using the --mtls flag. For this, use the following syntax:
      api-test test yaml-files
       --mTLS --certPath=location of certs folder
      
      Where, yaml-files is the location of the YAML file. For example, apic test test1.yaml.
    • For passing external configuration, run the CLI using the --config-file flag. For this, use the following syntax:
      api-test test yaml-files
        --config-file=location of config file
      
      Where, yaml-files is the location of the YAML file. For example, apic test test1.yaml. location of config file specifies the location of the configuration file.
    Note: Cert files must be named in the following format:
    • tls.crt - public key
    • tls.key- private key
    • ca.crt- CA certificate
    For more information about how the test is defined as a YAML file, see Test definition syntax.

    For more information about the assigning variables on a YAML configuration file, see Variable assignment in YAML configuration.