How do I prompt codex to generate unit tests for my code
Sameer Mahajan
25
Reputation points
How do I prompt codex (code-davinci-002) model to generate all the unit tests for my code? I understand from some posts that I should rather do it function by function for better results.
So I tried
# generate unit tests for
def add (n1, n2):
return n1 + n2
which gave
# generate unit tests for
def add (n1, n2):
return n1 + n2
def subtract (n1, n2):
return n1 - n2
def multiply (n1, n2):
return n1 * n2
def divide (n1, n2):
return n1 / n2
that sounds rather incorrect. Only once it gave correct result of
def test_add (n1, n2):
# with some correct statements with parameter. values
How do I ensure that it always gives correct results? Also how to make sure that it does thorough job (e.g. different types, 0 result, positive / negative results etc.)
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,080 questions
Sign in to answer