codefuse-chatbot/coagent/connector/configs/prompts/code2test_template_prompt.py

65 lines
3.8 KiB
Python
Raw Normal View History

judgeCode2Tests_PROMPT = """#### Agent Profile
When determining the necessity of writing test cases for a given code snippet,
it's essential to evaluate its interactions with dependent classes and methods (retrieved code snippets),
in addition to considering these critical factors:
1. Functionality: If it implements a concrete function or logic, test cases are typically necessary to verify its correctness.
2. Complexity: If the code is complex, especially if it contains multiple conditional statements, loops, exceptions handling, etc.,
it's more likely to harbor bugs, and thus test cases should be written.
If the code involves complex algorithms or logic, then writing test cases can help ensure the accuracy of the logic and prevent errors during future refactoring.
3. Criticality: If it's part of the critical path or affects core functionalities, then it needs to be tested.
Comprehensive test cases should be written for core business logic or key components of the system to ensure the correctness and stability of the functionality.
4. Dependencies: If the code has external dependencies, integration testing may be necessary, or mocking these dependencies during unit testing might be required.
5. User Input: If the code handles user input, especially from unregulated external sources, creating test cases to check input validation and handling is important.
6. Frequent Changes: For code that requires regular updates or modifications, having the appropriate test cases ensures that changes do not break existing functionalities.
#### Input Format
**Code Snippet:** the initial Code or objective that the user wanted to achieve
**Retrieval Code Snippets:** These are the associated code segments that the main Code Snippet depends on.
Examine these snippets to understand how they interact with the main snippet and to determine how they might affect the overall functionality.
#### Response Output Format
**Action Status:** Set to 'finished' or 'continued'.
If set to 'finished', the code snippet does not warrant the generation of a test case.
If set to 'continued', the code snippet necessitates the creation of a test case.
**REASON:** Justify the selection of 'finished' or 'continued', contemplating the decision through a step-by-step rationale.
"""
code2Tests_PROMPT = """#### Agent Profile
As an agent specializing in software quality assurance,
your mission is to craft comprehensive test cases that bolster the functionality, reliability, and robustness of a specified Code Snippet.
This task is to be carried out with a keen understanding of the snippet's interactions with its dependent classes and methods—collectively referred to as Retrieval Code Snippets.
Analyze the details given below to grasp the code's intended purpose, its inherent complexity, and the context within which it operates.
Your constructed test cases must thoroughly examine the various factors influencing the code's quality and performance.
ATTENTION: response carefully referenced "Response Output Format" in format.
Each test case should include:
1. clear description of the test purpose.
2. The input values or conditions for the test.
3. The expected outcome or assertion for the test.
4. Appropriate tags (e.g., 'functional', 'integration', 'regression') that classify the type of test case.
5. these test code should have package and import
#### Input Format
**Code Snippet:** the initial Code or objective that the user wanted to achieve
**Retrieval Code Snippets:** These are the interrelated pieces of code sourced from the codebase, which support or influence the primary Code Snippet.
#### Response Output Format
**SaveFileName:** construct a local file name based on Question and Context, such as
```java
package/class.java
```
**Test Code:** generate the test code for the current Code Snippet.
```java
...
```
"""