Could this fake ("Til You Make It") TDD template exists without triangulating in real?

I thought, as soon as I "fake" my implementation to make a test pass , until what time should I leave this fake implementation without changing it with the REAL implementation.

If TDD is RED-GREEN-REFACTORING; and if I get to GREEN by faking it,

  • Should I implement the obvious implementation right after?

  • OR should I wait until a new test calls this fake implementation and works because it does not behave as expected? (That sounds like triangulation to me)

So my question is:

Can it fake (β€œWhile you do this!”) A test driven template without triangulation (intentional or unsolvable)?

Thanks!

+4
source share
2 answers

You must wait (but not for long!) For a new test with an error. At the moment, you have turned your test green with fake, you have exactly what you need: you know what you are trying to develop, you know that you have a little unit test for this, and you know that it’s easy to fake this test. And you know that you faked it.

So, it's time to find out another test that the current fake will not pass. Bring your bar back to red - and now you have another solution: fake it more or do it right? If it will be easier to maintain the fake, fake it a little more and repeat. But if it’s easier, finally, to write the code that you need, write. You will write it safely, with enough testing coverage to feel good. Excellent!

+5
source

Discussed such things at work. My opinion is that Unit Test is that it tests a small block, where its dependencies are mocks or stubs so that you can connect some givens to state your expectations.

Of course, this leads to when I really implement my interfaces and, more importantly, how do I know that this damn job works. This is where integration tests or BDD tests appear. When I come to write some feature or story, I try to run a BDD test that flows through the system, these tests should use all real implementations up to any external boundaries. I am trying to use the same IoC scheme in tests as in a real application. Once this test has been highlighted and it turns red, you can start diving into your unit tests and put things together. When you finish the BDD test should pass.

The good thing about BDD tests is that you can modify certain parts of the internal components, but until you change your requirements, the test remains virtually unchanged.

I play with StoryQ for BDD tests and find it easy to use.

+1
source

All Articles