既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
#### 2.3、让AI根据代码解释制定测试计划
def generate_a_test_plan(full_code_explaination, unit_test_package=“pytest”):
prompt_to_explain_a_plan = f"“”
A good unit test suite should aim to:
- Test the function’s behavior for a wide range of possible inputs
- Test edge cases that the author may not have foreseen
- Take advantage of the features of
{unit_test_package}
to make the tests easy to write and maintain - Be easy to read and understand, with clean code and descriptive names
- Be deterministic, so that the tests always pass or fail in the same way
{unit_test_package}
has many convenient features that make it easy to write and maintain unit tests. We’ll use them to write unit tests for the function above.
For this particular function, we’ll want our unit tests to handle the following diverse scenarios (and under each scenario, we include a few examples as sub-bullets):
-“”"
prompt = full_code_explaination+prompt_to_explain_a_plan
response = gpt35(prompt)
return response, prompt
test_plan, prompt_to_get_test_plan = generate_a_test_plan(prompt_to_explain_code+code_explaination)
print(test_plan)
针对生成的测试计划,对AI制定了几点要求:
* 测试用例要覆盖更广的范围。
* 测试用例的边界要涉及到作者无法想到的场景。
* 充分利用pytest的特性。
* 确保测试用例简洁、易理解。
* 测试用例的结果是确定的,要么成功、要么失败。
输出结果:
Normal inputs:
- days
is a positive integer
- days
is 0
- Edge cases:
days
is a negative integerdays
is a floatdays
is a string
- Invalid inputs:
days
isNone
days
is a list
#### 2.4、根据测试计划生成测试代码
def generate_test_cases(function_to_test, unit_test_package=“pytest”):
starter_comment = “Below, each test case is represented by a tuple passed to the @pytest.mark.parametrize decorator”
prompt_to_generate_the_unit_test = f"“”
Before going into the individual tests, let’s first look at the complete suite of unit tests as a cohesive whole. We’ve added helpful comments to explain what each line does.
import {
unit_test_package} # used for our unit tests
{
function_to_test}
#{starter_comment}"""
full_unit_test_prompt = prompt_to_explain_code +