Skip to content

Setting Up a Project

Setting up a project in Condor is straightforward and ensures that your testing workflows are organized and efficient. Follow these steps to create and configure your Condor project.

Step 1: Initialize a New Project

Use the condor init command to create the basic structure for your project. Run the following command in your desired directory:

Terminal window
condor init collection
cd collection

This creates the following directory structure:

collection/
├── environments/
├── resources/
├── tests/
  • environments/: Store environment-specific configurations (e.g., base_url).
  • resources/: Define reusable resources such as HTTP requests.
  • tests/: Write test files organized by purpose (e.g., E2E, load, security).

Step 2: Configure an Environment

Navigate to the environments/ directory and create a file named development.condor:

base_url = "https://api.dev.example.com"

You can create additional environment files, such as production.condor or staging.condor, with their respective configurations.

Step 3: Define Resources

Define reusable HTTP resources in the resources/ directory. For example, create resources/users/get_user.condor:

http "get_user" {
method = "get"
path = "/user/{id}"
headers {
Authorization = "Bearer ${var.auth_token}"
}
}

This resource represents an HTTP GET request to retrieve user details.

Step 4: Write Tests

Write your tests in the tests/ directory. For example, create tests/e2e/users_test.condor:

test "get_user_test" {
name = "Get User Details"
request = http.get_user
variables {
auth_token = "your-auth-token"
id = "12345"
}
assert {
condition = resp.status == 200
error = "Expected status 200, got ${resp.status}."
}
assert {
condition = json::decode(resp.body).name != ""
error = "Expected a non-empty name in the response."
}
}

Step 5: Run Your Tests

Run tests using the Condor CLI. For example, to execute the get_user_test:

Terminal window
condor run collection/tests/e2e/users_test.condor

Condor will process the test, evaluate assertions, and display the results in your terminal.

Step 6: Integrate with CI/CD (Optional)

To run Condor tests as part of your CI/CD pipeline, add the test execution command to your pipeline configuration. For example, in a GitHub Actions workflow:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Condor
run: |
curl -LO https://condor.sh/download/condor-latest
chmod +x condor-latest
sudo mv condor-latest /usr/local/bin/condor
- name: Run Condor Tests
run: condor run collection/tests/

This configuration runs all tests in the tests/ directory during your CI/CD pipeline execution.


Your Condor project is now set up and ready to scale with your testing needs. For more details on advanced configurations and features, check out other guides in this documentation.