会议 · 推荐
本文目录
#基于大模型的智能化软件工程——机会与挑战
#如何使用大语言模型加速软件工程初期的功能测试?
一、基于大模型的智能化软件工程——机会与挑战
(可信AI评测)
由中国信息通信研究院云计算与大数据研究所(以下简称“中国信通院云大所”)和人工智能关键技术和应用评测工业和信息化部重点实验室(以下简称“实验室”)联合主办的“2023大模型工程化论坛”在京成功举办,线上线下共计三千多名专家参会。本次论坛以“论道大模型服务发展新思路”和“共谋AI高质效生产新篇章”为主题,围绕大模型等AI模型的生产、管理、应用和服务化等工程化阶段展开研讨。论坛邀请了北京大学讲席教授、计算机学院软件科学与工程系主任——谢涛,发表“基于大模型的智能化软件工程:机会与挑战”主题演讲。


谢涛教授介绍了智能化软件工程的发展历程,基于大模型的代码生成的兴起、应用和挑战,以及aiXcoder 近来的进展。他提出,面向智构件(Intelligently Constructed Components 智能化创建)的开发,是软件开发提质增效未来方向。未来,代码大模型值得大家关注的三个方向,即代码大模型的能力提升、代码大模型下游任务的生态建设和代码大模型时代的工程师教育和培训。
未来,中国信通院将持续推进AI4SE的技术研究、标准制定、评估测试、案例征集、产业活动等工作,与产学研用各方单位携手推进AI工程化、产业化进程,共筑AI4SE可信生态。
二、如何使用大语言模型加速软件工程初期的功能测试?
(原创 小董STEM学习空间 小董的STEM学习空间)
1. The Importance of Software Testing



and it will help us have productive conversations with our security expert colleagues.这将帮助我们与安全专家同事进行更高效的交流。
2. Manual Exploratory Testing


By working with an LLM to think through different types of testing activities, we can make life much easier for anyone testing your code.通过与大语言模型(LLM)合作思考不同类型的测试活动,我们可以大大简化测试人员的工作。

tasks = []defadd_task(task): tasks.append(task)returnf"Task '{task}' added."defremove_task(task):if task in tasks: tasks.remove(task)returnf"Task '{task}' removed."else:return"Task not found."deflist_tasks():return tasksIts functions include things like adding tasks, removing tasks, and listing tasks.它的功能包括添加任务、移除任务和列出任务。 So it would make sense for you to try each one of these.因此,尝试每一项功能是有意义的。
Here's an example usage code.以下是一个使用示例代码。
# Example usageprint(add_task("Buy groceries"))# Output: Task 'Buy groceries' added.print(add_task("Read a book")) # Output: Task 'Read a book' added.print(list_tasks()) # Output: ['Buy groceries', 'Read a book']print(remove_task("Read a book"))# Output: Task 'Read a book' removed.print(list_tasks())# Output: ['Buy groceries']
这些是相当直接的测试,方法会按我们的预期工作。
Next, we might move on to testing some edge cases.接下来,我们可以测试一些边界情况。
For instance, what happens when we try to remove a task that doesn't exist?例如,当我们尝试移除一个不存在的任务时会发生什么?
print(remove_task("Go for a run")) # Output: Task not found.There is another issue that we may have found, and it's not immediately obvious, and that is we can add an empty task.我们可能发现另一个问题,这个问题并不显而易见,那就是我们可以添加一个空任务。
print(add_task("")) # Output: Task '' added.print(list_tasks()) # Output: ['Buy groceries', '']
❝Prompt: You are a software engineer and tester who is curious and who likes to go through code looking for edge cases. There's some Python code here -- please explore it and find and issues that might cause bugs or poor functionality:


ChatGPT found a number of issues and suggested some potential improvements.ChatGPT发现了一些问题并建议了一些潜在的改进。


There's various other things, such as task duplication. It does not check for duplicate tasks when we do
add_task.还有其他问题,比如任务重复。在执行add_task时,它没有检查任务是否重复。
Model Response 2: Revised Code
Benefits of the Improved Code:
Encapsulation: Tasks are now encapsulated within a TaskManagerclass.
classTaskManager:def__init__(self): self.tasks = []Validation: Input is validated to ensure tasks are non-empty strings. Duplicate Handling: Duplicates are rejected with an appropriate message.
defadd_task(self, task):ifnot task ornot isinstance(task, str):return"Invalid task. Task must be a non-empty string."if task in self.tasks:returnf"Task '{task}' already exists." self.tasks.append(task)returnf"Task '{task}' added."defremove_task(self, task):if task in self.tasks: self.tasks.remove(task)returnf"Task '{task}' removed."else:returnf"Task '{task}' not found."User-Friendly Output: list_tasks() provides a numbered list, making it easier to read. Safety: Internal state is protected by the class.
deflist_tasks(self):ifnot self.tasks:return"No tasks available."return"\n".join(f"{i+1}. {task}"for i, task in enumerate(self.tasks))Add unit tests for edge cases, such as removing tasks that do not exist, adding Noneor empty tasks.
# Example usage of TaskManagerif __name__ == "__main__": task_manager = TaskManager()# Adding tasks print(task_manager.add_task("Read a book")) # Output: Task 'read a book' added. print(task_manager.add_task("Go jogging")) # Output: Task 'go jogging' added. print(task_manager.add_task("Read a book")) # Output: Task 'read a book' already exists.# Listing tasks print(task_manager.list_tasks())# Output:# read a book# go jogging# Removing a task print(task_manager.remove_task("Read a book")) # Output: Task 'read a book' removed. print(task_manager.remove_task("Watch TV")) # Output: Task 'watch tv' not found.# Listing tasks after removal print("Tasks after removal:") print(task_manager.list_tasks())# Output:# go jogging# Adding an invalid task print(task_manager.add_task("")) # Output: Invalid task. Task must be a non-empty string. print(task_manager.add_task(None)) # Output: Invalid task. Task must be a non-empty string. print(task_manager.add_task(" ")) # Output: Invalid task. Task must be a non-empty string.
3. Manual Functional Testing

import unittestclassTestTodoList(unittest.TestCase):defsetUp(self):global tasks tasks = []In the test_add_taskmethod, you check if a task is added successfully and then you verify that it appears in the task list.在test_add_task方法中,您会检查任务是否成功添加,并验证它是否出现在任务列表中。
deftest_add_task(self): self.assertEqual(add_task("Buy groceries"), "Task 'Buy groceries' added.") self.assertIn("Buy groceries", tasks)For test_remove_task, you add the task first and then remove it to check if it's removed from the list.在test_remove_task方法中,您先添加任务,然后删除它以检查它是否从列表中移除。
deftest_remove_task(self): add_task("Read a book") self.assertEqual(remove_task("Read a book"), "Task 'Read a book' removed.") self.assertNotIn("Read a book", tasks)The test_remove_nonexistent_taskmethod verifies that trying to remove a non-existent task will return the correct message.test_remove_nonexistent_task方法验证尝试删除不存在的任务是否会返回正确的消息。
deftest_remove_nonexistent_task(self): self.assertEqual(remove_task("Go for a run"), "Task not found.")The test_list_tasksmethod checks if the list of tasks is returned correctly.test_list_tasks方法检查任务列表是否正确返回。
deftest_list_tasks(self): add_task("Buy groceries") add_task("Read a book") self.assertEqual(list_tasks(), ["Buy groceries", "Read a book"])And test_add_empty_taskchecks if the application handles adding an empty task.test_add_empty_task方法检查应用程序是否处理添加空任务的情况。
deftest_add_empty_task(self): self.assertEqual(add_task(""), "Invalid task. Task must be a non-empty string.") self.assertNotIn("", tasks)unittest.main(argv=[''], verbosity=2, exit=False)

4. Summary


1、如您转载本公众号原创内容必须注明出处。
2、本公众号转载的内容是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请作者或发布单位与我们联系,我们将及时进行修改或删除处理。
3、本公众号文中部分图片来源于网络,版权归原作者所有,如果侵犯到您的权益,请联系我们删除。
4、本公众号发布的所有内容,并不意味着本公众号赞同其观点或证实其描述。其原创性以及文中陈述文字和内容未经本公众号证实,对本文全部或者部分内容的真实性、完整性、及时性我们不作任何保证或承诺,请浏览者仅作参考,并请自行核实。
夜雨聆风