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.
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 = )
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)
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.
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.
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.
发布评论
评论(6)
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.
这个问题太笼统了,我唯一能说的是,在修复某些东西之前,你应该确保你已经进行了测试。
The question is too general, and the only thing I can state is that before fixing something you should make sure you have tests.
我认为,当您开始时,重要的是要学会使一小部分代码尽可能独立。然后,您可以轻松测试每个函数和每个对象的行为是否应该在进行时发现缺陷。注释掉问题部分以隔离问题所在;学习很重要。然后开始学习单元测试。这是注释问题代码的一种奇特方式 = )
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 = )
在进行具有良好代码收敛性的单元测试之后,我建议您考虑运行静态代码分析并在探查器中运行相当一部分代码,以查看它是否在您期望的代码区域中繁忙(并创建某种您期望的对象)
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)
积极主动地进行设置,以便更轻松地检测和修复缺陷。与生活中的大多数事情一样,如果您在遇到问题之前遵守纪律,您会发现处理这些问题会容易得多。
完成此操作后,您可以使用适当的数据运行单元测试来重现错误,然后使用单元测试修复错误以确定何时修复错误。
更新您的单元测试以弥补此缺陷。
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.
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.
我使用以下步骤来修复错误:
步骤 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.