缺陷修复的最佳实践?

发布于 2024-10-07 04:28:11 字数 1435 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

热情消退 2024-10-14 04:28:11

TDD 表示首先应该实施重现问题的测试。然后修复错误并再次运行测试。如果所有测试都通过,那么您就完成了。否则继续修复。

TDD says that first you should implement test(s) that reproduce the problem. Then fix the bug and run tests again. If all tests pass you are done. Otherwise continue fixing.

懷念過去 2024-10-14 04:28:11

这个问题太笼统了,我唯一能说的是,在修复某些东西之前,你应该确保你已经进行了测试。

The question is too general, and the only thing I can state is that before fixing something you should make sure you have tests.

2024-10-14 04:28:11

我认为,当您开始时,重要的是要学会使一小部分代码尽可能独立。然后,您可以轻松测试每个函数和每个对象的行为是否应该在进行时发现缺陷。注释掉问题部分以隔离问题所在;学习很重要。然后开始学习单元测试。这是注释问题代码的一种奇特方式 = )

I think when you are starting out its important to learn to keep small segments of your code as independent as possible. Then you can easily test that each function and each object behaves like it should finding the flaws as you go. Commenting out problem sections to isolate where the issue is; is important to learn. Then start learning about unit testing. Which is a fancy way of commenting out problem code = )

放低过去 2024-10-14 04:28:11

在进行具有良好代码收敛性的单元测试之后,我建议您考虑运行静态代码分析并在探查器中运行相当一部分代码,以查看它是否在您期望的代码区域中繁忙(并创建某种您期望的对象)

After having unit tests with good code converage, I would suggest you look at running a static code analysis and run a decent portion of your code in a profiler to see if it is busy in the areas of cod eyou expect (and creates the sort of objects you expect)

萧瑟寒风 2024-10-14 04:28:11

积极主动地进行设置,以便更轻松地检测和修复缺陷。与生活中的大多数事情一样,如果您在遇到问题之前遵守纪律,您会发现处理这些问题会容易得多。

  1. 首先编写单元测试:有些人觉得这令人困惑,但它确实有效。这对于在实现代码之前识别极端情况和非明显问题非常有用。显然,您的代码必须有某种框架,但我发现在开始之前我至少已经在脑子里有了这个框架。
  2. 编写代码:使用单元测试逐步验证代码。

完成此操作后,您可以使用适当的数据运行单元测试来重现错误,然后使用单元测试修复错误以确定何时修复错误。

更新您的单元测试以弥补此缺陷。

Be proactive in setting things up so that the detection and fixing of defects is made easier. As with most things in life, if you apply discipline before you encounter issues you find dealing with those issues much easier.

  1. Write your unit test first: Some people find this bewildering but it really works. This is very useful in identifying corner cases, non-obvious issues BEFORE you implement the code. Obviously you'll have to have some sort of skeleton for your code but I find that I have that at least in my head before starting.
  2. Write the code: use the unit test to verify the code stepwise.

With this in place you can run the unit test with the appropriate data to reproduce the bug and then you fix the bug using the unit test to decide when the bug is fixed.

Update your unit test to cover this defect.

萌能量女王 2024-10-14 04:28:11

我使用以下步骤来修复错误:

步骤 1. 识别错误。

向报告者索要错误的屏幕截图。
尝试在给定场景中重现该错误。

步骤 2. 分析错误

捕获日志并尝试仔细分析。

第 3 步:与团队讨论您的发现

寻找预期行为并与测试人员讨论并验证您的潜在解决方案。

第 4 步:覆盖横向损坏。

尝试看看您的潜在修复是否会导致系统中出现其他一些错误。

第 5 步.修复错误。

修复错误!

步骤 7. 验证解决方案。

运行所有测试脚本并检查它们是否全部通过。如果他们失败了,请纠正他们。

I use below steps to fix a bug:

Step 1. Identify the bug.

Ask for screenshots from reporter of the bug.
Try to reproduce the bug in given scenario.

Step 2. Analyze the error

Capture the logs and try to analyse it carefully.

Step 3. Discuss your findings with the team

Look for the expected behavior and discuss this with the tester and verify your potential solution.

Step 4. Cover lateral damage.

Try to look if your potential fix will cause some other bug in the system.

Step 5. Fix the error.

Fix the error!

Step 7. Validate the solution.

Run all the test scripts and check that they all pass. If they fail correct them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文