Test Functions
Test Functions are components within a test that contain the exact instructions for performing a specific validation or action. They provide the precise step-by-step guidance needed to execute the test.
Overview
Test Functions are the most granular level of test definition in Test & Accept. They contain the actual instructions that testers follow to verify whether a criterion is met.
Test Functions:
- Provide precise step-by-step instructions
- Define exactly how to perform the test
- Specify what to observe or measure
- Detail the expected results
- Form the actionable part of test execution
The Test Function Model
- Name
id
- Type
- string
- Description
Unique identifier for the test function.
- Name
sectionId
- Type
- string
- Description
ID of the test section this function belongs to.
- Name
step
- Type
- number
- Description
The step number within the section.
- Name
instructions
- Type
- string
- Description
The exact instructions to perform.
- Name
expectedResult
- Type
- string
- Description
What should be observed when this function is executed correctly.
- Name
actualResult
- Type
- string
- Description
What was actually observed during execution (filled during test runs).
- Name
status
- Type
- string
- Description
Status of this function (e.g., "not_run", "passed", "failed").
- Name
notes
- Type
- string
- Description
Additional notes or observations.
- Name
createdAt
- Type
- timestamp
- Description
Timestamp of when the function was created.
- Name
updatedAt
- Type
- timestamp
- Description
Timestamp of when the function was last updated.
Creating Test Functions
Via the UI
- Navigate to a test section
- Click "Add Function"
- Enter function details:
- Step number
- Instructions
- Expected result
- Click "Save Function"
Via the API
// Create test functions within a section
const testSection = {
title: "User Login Process",
functions: [
{
step: 1,
instructions: "Open the application in a web browser and navigate to https://app.example.com",
expectedResult: "The login page loads with username and password fields visible"
},
{
step: 2,
instructions: "Enter 'testuser@example.com' in the username field",
expectedResult: "The email address is accepted and displayed in the username field"
},
{
step: 3,
instructions: "Enter 'TestPass123!' in the password field",
expectedResult: "The password is masked with dots as it is typed"
},
{
step: 4,
instructions: "Click the 'Sign In' button",
expectedResult: "The page shows a loading indicator, then redirects to the dashboard at /dashboard"
},
{
step: 5,
instructions: "Verify the user's name 'Test User' appears in the top-right corner",
expectedResult: "The text 'Test User' is visible in the header navigation area"
}
]
};
Writing Effective Test Functions
Be Specific and Precise
Test functions should leave no room for interpretation:
❌ Vague: "Check if the login works" ✅ Specific: "Enter 'user@example.com' in the email field and 'Pass123' in the password field, then click the blue 'Login' button"
Include Exact Values
Always specify exact values, locations, and expected outcomes:
❌ Unclear: "Enter valid credentials" ✅ Clear: "Enter username: 'testuser01' and password: 'SecurePass123!'"
Define Observable Results
Expected results should be observable and verifiable:
❌ Subjective: "The page should load quickly" ✅ Observable: "The dashboard page loads and displays the text 'Welcome, John Doe' within 3 seconds"
Types of Test Functions
Action Functions
Instructions that require the tester to perform an action:
Instructions: "Click the 'Submit Order' button at the bottom of the form"
Expected Result: "The button becomes disabled and shows 'Processing...' text"
Verification Functions
Instructions that require the tester to verify a state:
Instructions: "Check the order status in the Orders table"
Expected Result: "The order appears with status 'Pending' and today's date"
Data Entry Functions
Instructions for entering specific data:
Instructions: "Enter '555-0123' in the Phone Number field"
Expected Result: "The phone number is formatted as '(555) 012-3456' automatically"
Best Practices
- Atomic Steps: Each function should perform one discrete action or verification
- Sequential Order: Number steps in the order they should be executed
- No Assumptions: Don't assume the tester has prior knowledge
- Exact Instructions: Specify exact values, locations, and actions
- Verifiable Results: Expected results must be objectively observable
- Error Conditions: Include functions that test error scenarios
- Consistent Format: Use a consistent writing style across all functions
Function Execution
During test execution, each function:
- Is performed in sequence
- Has its actual result recorded
- Is marked as passed or failed
- Can have notes added for clarification
Relationship to Test Structure
The complete hierarchy:
- Test: Verifies a criterion
- Test Section: Groups related functions
- Test Function: The exact instructions
Each function belongs to exactly one section, and each section belongs to exactly one test.
API Reference
Test functions are typically managed as part of the test structure. See the Tests API Reference for endpoints that include function management.
For complete API details on test function management, refer to the API Reference.