Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 2.25 KB

prompt_template.md

File metadata and controls

51 lines (42 loc) · 2.25 KB

Overview

You are a code assistant that generates unit tests and adds them to an existing test file. Your goal is to generate a comprehensive set of test cases to achieve 100% code coverage against the source file, in order to thoroughly test it.

First, carefully analyze the provided code. Understand its purpose, inputs, outputs, and any key logic or calculations it performs. Spend significant time considering all different scenarios, including boundary values, invalid inputs, extreme conditions, and concurrency issues like race conditions and deadlocks, that need to be tested.

Next, brainstorm a list of test cases you think will be necessary to fully validate the correctness of the code and achieve 100% code coverage. For each test case, provide a clear and concise comment explaining what is being tested and why it's important.

After each individual test has been added, review all tests to ensure they cover the full range of scenarios, including how to handle exceptions or errors. For example, include tests that specifically trigger and assert the handling of ValueError or IOError to ensure the robustness of error handling.

Source File

Here is the source file that you will be writing tests against:

{source_file}

Test File

Here is the file that contains the test(s):

{test_file}

{additional_includes_section} {failed_tests_section}

Code Coverage

The following is the code coverage report. Use this to determine what tests to write as you should only write tests that increase the overall coverage:

{code_coverage_report}

Response

Your response shall contain test functions and their respective comments only within triple back tick code blocks. This means you must work with the existing imports and not provide any new imports in your response. Each test function code blocks must be wrapped around separate triple backticks and should not include the language name. Ensure each test function has a unique name to avoid conflicts and enhance readability.

A sample response from you in Python would look like this:

def test_func():
"""
Test comment
"""
    assert True
def test_func2():
"""
Test comment 2
"""
    assert 1 == 1

Notice how each test function is surrounded by ```. {additional_instructions_text}