Back to Repositories

Testing Workflow Generation Implementation in TaskMatrix

Unit test suite that validates the workflow generation functionality of the lowCodeLLM module, specifically testing the get_workflow method’s ability to process task prompts and generate valid workflow JSON outputs.

Test Coverage Overview

The test suite focuses on validating the get_workflow method’s core functionality by processing multiple test cases from a JSON file.

  • Tests workflow generation for various task prompts
  • Verifies JSON output structure and validity
  • Ensures minimum workflow length requirements
  • Handles multiple test cases iteratively

Implementation Analysis

Implements a straightforward testing approach using Python’s built-in assert statements to validate workflow generation results.

The test utilizes JSON file-based test cases and employs systematic iteration through test scenarios. The implementation leverages the lowCodeLLM class with specific configuration parameters (0.5, 0) for consistent testing conditions.

Technical Details

  • Uses Python’s json module for test case parsing
  • Implements sys.path manipulation for module imports
  • Relies on external JSON test case file
  • Configures lowCodeLLM instance with specific parameters
  • Utilizes assert statements for validation

Best Practices Demonstrated

The test demonstrates clean testing practices with clear separation of test data and logic.

  • Externalized test cases in JSON format
  • Proper module import handling
  • Consistent assertion patterns
  • Clear test method naming
  • Modular test structure

chenfei-wu/taskmatrix

LowCodeLLM/src/test/test_get_workflow.py

            
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import json
import sys
import os
sys.path.append(os.getcwd())

def test_get_workflow():
    from lowCodeLLM import lowCodeLLM
    cases = json.load(open("./test/testcases/get_workflow_test_cases.json", "r"))
    llm = lowCodeLLM(0.5, 0)
    for c in cases:
        task_prompt = c["task_prompt"]
        result = llm.get_workflow(task_prompt)
        assert len(json.loads(result)) >= 1