Skip to content

Quick Start Tutorials

Quickly get up and running with Condor by following these simple tutorials. These examples demonstrate how to set up, write, and execute tests in just a few steps.

Tutorial 1: API Status Check

Step 1: Initialize a Collection

Use the condor init command to create the basic directory structure for your Condor project:

Terminal window
condor init collection
cd collection

Step 2: Define a Resource

Navigate to the resources/ directory and create a new file named status_check.condor with the following content:

http "status_check" {
method = "get"
path = "/status"
headers {
Accept = "application/json"
}
}

Step 3: Write a Test

Navigate to the tests/ directory and create a new file named status_test.condor with this content:

test "status_check" {
name = "API Status Check"
request = http.status_check
assert {
condition = resp.status == 200
error = "Expected status 200, got ${resp.status}."
}
assert {
condition = json::decode(resp.body).status == "ok"
error = "Expected response status to be 'ok', but got ${json::decode(resp.body).status}."
}
}

Step 4: Run the Test

Execute the test with the following command:

Terminal window
condor run tests/status_test.condor

You should see the test results displayed in your terminal.


Tutorial 2: Parameterized Testing

Step 1: Define a Parameterized Resource

Create a new file in the resources/ directory named find_pet.condor:

http "find_pet" {
method = "get"
path = "/pet/findByStatus"
query {
status = var.status
}
headers {
Content-Type = "application/json"
}
}

Step 2: Write a Test

In the tests/ directory, create find_pet_test.condor with the following content:

test "find_pet" {
name = "Find Pet by Status"
request = http.find_pet
variables {
status = "available"
}
assert {
condition = resp.status == 200
error = "Expected status 200, got ${resp.status}."
}
assert {
condition = list::length(json::decode(resp.body)) > 0
error = "Expected at least one pet in the response."
}
}

Step 3: Run the Test

Run the test using:

Terminal window
condor run tests/find_pet_test.condor

This will execute the test for the available status. Modify the status variable to test different scenarios (e.g., sold, pending).


These tutorials provide a simple starting point for exploring Condor. For more advanced features, check out the Guides section.