Update app.py
Browse files
app.py
CHANGED
@@ -295,58 +295,27 @@ class TestCaseGenerator:
|
|
295 |
|
296 |
snippet = self.functions[func]
|
297 |
|
298 |
-
prompt
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
- Create at least 3-5 test cases that cover different scenarios
|
310 |
-
- Include normal cases, edge cases, and potential error conditions
|
311 |
-
- Ensure that the test cases collectively cover all branches and logic paths in the function
|
312 |
-
|
313 |
-
4. For each test case, provide:
|
314 |
-
- A brief description of the test scenario
|
315 |
-
- Input values for the function parameters
|
316 |
-
- The expected output or behavior
|
317 |
-
- An assert statement in the appropriate syntax for the given programming language
|
318 |
-
|
319 |
-
5. Calculate the test coverage percentage:
|
320 |
-
- Determine the number of code paths or branches in the function
|
321 |
-
- Count how many of these paths are covered by your test cases
|
322 |
-
- Calculate the percentage: (covered paths / total paths) * 100
|
323 |
-
|
324 |
-
6. Present your output in the following format:
|
325 |
-
<unit_tests>
|
326 |
-
<test_case>
|
327 |
-
<description>Description of the test case</description>
|
328 |
-
<input>Input values for the function</input>
|
329 |
-
<expected_output>Expected output or behavior</expected_output>
|
330 |
-
<assert_statement>Assert statement in the appropriate language syntax</assert_statement>
|
331 |
-
</test_case>
|
332 |
-
<!-- Repeat for each test case -->
|
333 |
-
</unit_tests>
|
334 |
-
|
335 |
-
<test_coverage>
|
336 |
-
<percentage>Calculated test coverage percentage</percentage>
|
337 |
-
<explanation>Brief explanation of how the percentage was calculated</explanation>
|
338 |
-
</test_coverage>
|
339 |
-
|
340 |
-
Remember to adapt your assert statements and syntax to the specific programming language provided. If you're unsure about the exact syntax for a particular language, use a general pseudocode format that clearly conveys the assertion logic.
|
341 |
"""
|
|
|
342 |
resp = self.generate_response(prompt)
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
return resp
|
351 |
|
352 |
def run(self):
|
|
|
295 |
|
296 |
snippet = self.functions[func]
|
297 |
|
298 |
+
prompt=f""" Your task is to generate unit test cases for this function : \n\n{snippet}\
|
299 |
+
\n\n Generate between 3 to 8 unique unit test cases. Include couple of edge cases as well.
|
300 |
+
\n\n Calculate the test case coverage and display in the response.
|
301 |
+
\n\n All the test cases should have the mandatory assert statement.
|
302 |
+
\n\n Every test case should be defined as a method inside the class.
|
303 |
+
\n\n All the test cases should have textual description.
|
304 |
+
\n\n Politely refuse if the function is not suitable for generating test cases.
|
305 |
+
\n\n There should be no duplicate and incomplete test case.
|
306 |
+
\n\n Avoid generating repeated statements.
|
307 |
+
\n\n Recheck your response before generating.
|
308 |
+
\n\n Do not share the last Test Case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
"""
|
310 |
+
|
311 |
resp = self.generate_response(prompt)
|
312 |
|
313 |
+
post_prompt = f"""Except the last test case, display everything that is present in this end to end: \n\n{resp}\
|
314 |
+
\n\n - Do not add anything extra. Just copy and paste everything except the last test case.
|
315 |
+
\n\n - Do not mention the count of total number of test cases in the response.
|
316 |
+
\n\n - Do not mention this sentence - "I have excluded the last test case as per your request"
|
317 |
+
"""
|
318 |
+
post_resp = self.generate_response(post_prompt)
|
319 |
return resp
|
320 |
|
321 |
def run(self):
|