Ask Your Question
4

How does modifying my test help in making my code pass with TDD?

asked 2023-06-10 09:37:59 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-10 09:38:02 +0000

pufferfish gravatar image

When practicing Test-driven development (TDD), modifying the tests can help in making the code pass by following these steps:

  1. Write a failing test: First, write a test that will initially fail because there is no corresponding code to pass it.

  2. Modify the test: Analyze the failing test and modify it so that it is easier to pass. This means that the test should be simplified, and irrelevant details should be removed.

  3. Run the modified test: Once the test is modified, run it to see if it passes or fails. If it fails, then modify the test again until it is simple enough to pass.

  4. Write code to pass the test: After the test has been simplified, write the code to pass it.

  5. Refactor the code: Once the code has been written, refactor it to improve its quality, readability, and maintainability.

By modifying the test, we can break down the problem into smaller, easier-to-solve parts, which ultimately helps in making the code pass with TDD. Additionally, modifying the test ensures that we write code that is specific to the requirements we defined in the test. This approach leads to better quality code that meets the requirements accurately.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-10 09:37:59 +0000

Seen: 11 times

Last updated: Jun 10 '23