Rerun all the tests every time the implementation code changes.
每次实现代码更改时重新运行所有测试。
This ensures that there is no unexpected side-effect caused by code changes.
这可确保不会因代码更改而导致意外的副作用。
Every time any part of the implementation code changes, all tests should be run. Ideally, tests are fast to execute and can be run by a developer locally. Once code is submitted to the version control, all tests should be run again to ensure that there was no problem due to code merges. This is especially important when more than one developer is working on the code. CI tools, such as Jenkins, Hudson, Travind, Bamboo, and Go-CD should be used to pull the code from the repository, compile it, and run tests.
每次实现代码的任何部分更改时,都应该运行所有测试。 理想情况下,测试可以快速执行并且可以由开发人员在本地运行。 一旦代码提交给版本控制,所有的测试都应该重新运行,以确保没有由于代码合并引起的问题。 当有多个开发人员在处理代码时,这一点尤其重要。 应该使用 CI 工具,例如 Jenkins、Hudson、Travind、Bamboo 和 Go-CD,从存储库中提取代码、编译它并运行测试。
@@ -464,9 +464,9 @@ public void whenReceiveCommandsFThenForward() {
我们已经谈到了编写通过规范的最简单的代码的重要性。
Write the simplest code to pass the test. This ensures a cleaner and clearer design and avoids unnecessary features
编写最简单的代码来通过测试。 这确保了更清晰、更清晰的设计,并避免了不必要的功能
The idea is that the simpler the implementation, the better and easier it is to maintain the product. The idea adheres to the KISS principle. It states that most systems work best if they are kept simple rather than made complex; therefore, simplicity should be a key goal in design and unnecessary complexity should be avoided.
这个想法是实施越简单,维护产品就越好、越容易。 这个想法遵循 KISS 原则。 它指出,大多数系统如果保持简单而不是变得复杂,则效果最佳; 因此,简单应该是设计的一个关键目标,应该避免不必要的复杂性。
这是一个应用此规则的好机会。您可能倾向于编写类似以下内容的代码:
...
...
@@ -535,11 +535,11 @@ public void receiveCommands(String commands) {
If all the implementation code that can be affected has tests and if they are all passing, it is relatively safe to refactor. In most cases, there is no need for new tests; small modifications to existing tests should be enough. The expected outcome of refactoring is to have all the tests passing both before and after the code is modified.
Implement surface detection before each move to a new position. If a command encounters a surface, the ship aborts the move, stays on the current position, and reports the obstacle.