CodePhoenix

Testing Code Microservice đź’»

Descrizione

Il microservizio di Testing confronta la funzionalitĂ  del codice originale con quella del codice rifattorizzato. Un agente dedicato analizza e verifica che il nuovo codice mantenga la stessa funzionalitĂ  del codice originale, garantendo che non ci siano regressioni o cambiamenti non desiderati.

Architettura del Microservizio

Il microservizio è progettato per eseguire i task di testing in maniera sequenziale. Un agente principale, Code Tester, esegue il compito di confrontare la funzionalità del codice originale con quella del codice rifattorizzato.

Testing Microservice

Code Tester

Questo agente si occupa di testare il codice, verificando che il nuovo codice rifattorizzato mantenga la stessa funzionalitĂ  del codice originale.

  1. Input: Riceve il codice originale, il risultato dell’analisi del codice originale e il nuovo codice rifattorizzato.
  2. Testing: Confronta la funzionalitĂ  del codice originale e del codice rifattorizzato per vari input, garantendo che producano gli stessi output.
  3. Output: Fornisce un report dettagliato sulla equivalenza funzionale o un risultato binario che indica se il nuovo codice ha la stessa funzionalitĂ  del codice originale.
code_tester = Agent(
    role='Code Tester',
    goal='Test and compare the functionality of old and new code',
    backstory="""You are an experienced QA engineer with expertise in testing complex systems.
    Your role is to ensure that refactored code maintains the same functionality as the original.""",
    verbose=True,
    allow_delegation=False,
    llm=os.environ["LLM"],
)

WorkFlow - Code Tester

WorkFlow - Code Tester

Parametri - Code Tester

Task - Code Tester

task1 = Task(
    description=f"""Compare the functionality of the old and new code.
    Ensure that the refactored code produces the same output as the original code for various inputs.
    I forbid you from fake testing the code, but instead, just analyze the code and say if the refactored code has the same functionality as the original code or not, without any unit testing.
    Old Code: {old_code},
    Old Code Analysis Result: {old_code_analysis_result},
    New Code: {new_code_to_test}""",
    expected_output="Detailed report on functional equivalence and any discrepancies" if not binary_response else "A single binary number, 0 or 1, indicating if the refactored code has DIFFERENT functionality than the original code.",
    agent=code_tester,
)

Parametri - Task

Crew - Testing Agent Analysis

La crew risulta essere l’insieme degli agenti che vengono creati e a cui vengono assegnati i task.

# Instantiate the crew for testing
testing_crew = Crew(
    agents=[code_tester],
    tasks=[task1],
    verbose=True,
    process=Process.sequential
)

# Execute the testing
test_result = testing_crew.kickoff()

Parametri - Crew