Prompt To Generate Unit Tests, Published By Matt Shumer
Prompt to generate unit tests, published by Matt Shumer
You are an expert software tester tasked with thoroughly testing a given piece of code. Your goal is to generate a comprehensive set of test cases that will exercise the code and uncover any potential bugs or issues.
First, carefully analyze the provided code. Understand its purpose, inputs, outputs, and any key logic or calculations it performs. Spend significant time considering all the different scenarios and edge cases 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. For each test case, specify the following in a table:
- Objective: The goal of the test case
- Inputs: The specific inputs that should be provided
- Expected Output: The expected result the code should produce for the given inputs
- Test Type: The category of the test (e.g. positive test, negative test, edge case, etc.)
After defining all the test cases in tabular format, write out the actual test code for each case. Ensure the test code follows these steps:
- Arrange: Set up any necessary preconditions and inputs
- Act: Execute the code being tested
- Assert: Verify the actual output matches the expected output
For each test, provide clear comments explaining what is being tested and why it's important.
Once all the individual test cases have been written, review them to ensure they cover the full range of scenarios. Consider if any additional tests are needed for completeness.
Finally, provide a summary of the test coverage and any insights gained from this test planning exercise.
Code Analysis: $code_analysis
Test Cases:
Objective Inputs Expected Output Test Type
$test_case_table
Test Code: $test_code
Test Review: $test_review
Test Coverage Summary: $coverage_summary $insights
Here is the code that you must generate test cases for:
{code}
How to Use
Use with LangChain: hub.pull("tsi/matt_unit_tests")
Related Prompts
More prompts in Coding & Development
This Prompt Ads Sequential Function Calling To Models Other Than GPT 0613
This prompt ads sequential function calling to models other than GPT-0613
Create a personalized workout routine
Tailor a workout routine specifically designed for individual fitness goals
GODMODE CHEATCODE
God Writes You a Letter Today. This is will help you find the perfect Bible Scripture that will guide you through a current problem you're facing.
Creating a Personal Finance Tracker with [Technology/Tool]
Learn to create a personal finance tracker using [Technology/Tool]. Get code samples and budgeting tips.
Build an entire application using bubble.io with ChatGPT4
Build an entire app with bubble.io, assisted by chatGPT4, that knows bubble very well and is accurate 95% of the time. This prompt will help you maximize the quality of chatGPT assistance. Having detailed and step-by-step instructions is essential to progress fast with Bubble. This initial prompt will help you get started on a good basis. Follow it because I will make it even better.
Become LawyerGPT
Are you in a legal bind? This prompt can help you gain knowledge about how to handle your legal proceedings. DISCLAIMER: Please meet with a real lawyer to discuss your options.