Spaces:
Sleeping
Sleeping
from core.base_agent import BaseAgent | |
from core.database import db | |
from typing import Dict, Any | |
class TesterAgent(BaseAgent): | |
def __init__(self): | |
super().__init__("Tester") | |
self.create_chain(""" | |
You are a Software Tester. Your task is to create comprehensive test cases and execute them on the given code. | |
Code to Test: | |
{input} | |
Create test cases that: | |
1. Cover all user stories and acceptance criteria | |
2. Include unit tests, integration tests, and system tests | |
3. Test edge cases and error conditions | |
4. Follow testing best practices | |
5. Include test data and expected results | |
Please provide detailed test cases with clear steps and expected outcomes. | |
""") | |
async def create_test_cases(self, code: str) -> Dict[str, Any]: | |
"""Create test cases for the given code""" | |
result = await self.process({"input": code}) | |
# Store the test cases in the database | |
db.store_artifact( | |
"test_cases", | |
result, | |
{ | |
"type": "test_case", | |
"source": "tester", | |
"status": "created" | |
} | |
) | |
return { | |
"status": "success", | |
"test_cases": result, | |
"message": "Test cases created successfully" | |
} | |
async def execute_tests(self, code: str, test_cases: str) -> Dict[str, Any]: | |
"""Execute test cases on the given code""" | |
result = await self.process({ | |
"input": f"Code:\n{code}\n\nTest Cases:\n{test_cases}" | |
}) | |
# Store the test results in the database | |
db.store_artifact( | |
"test_results", | |
result, | |
{ | |
"type": "test_result", | |
"source": "tester", | |
"status": "executed" | |
} | |
) | |
return { | |
"status": "success", | |
"test_results": result, | |
"message": "Tests executed successfully" | |
} |