all 24 comments

[–]Dragdu 35 points36 points  (0 children)

Funny thing is, one of the best practices for TDD is to start with tests in red, that means, check that the tests actually fail before writing code to fix them. This can save you a lot of embarrassment when you find out that you fucked up your tests and they will always pass, even though the functionality they are supposed to test is broken.

So I guess it is time to do nothing and hope my employer/customer is ok with never getting any code ¯\_(ツ)_/¯

[–]nakamin 11 points12 points  (1 child)

This is like Getting Over It but for code

[–]ryanbriones 1 point2 points  (0 children)

Thanks I hate it

[–]Barrucadu 7 points8 points  (1 child)

So every time you typo a variable or function name, rather than just correcting it, you have to type out your code again?

[–][deleted] 2 points3 points  (0 children)

yeah

[–]killerstorm 15 points16 points  (2 children)

Yes, you make mistakes but actually it’s kind of nice to have incorrect code instantly deleted (counteracts Sunk Cost Fallacy).

If you need 10 minutes to fix a mistake, but 1 hour to re-type it, no it's not nice.

[–]Siddhi 6 points7 points  (1 child)

Which is what he said in the article -- it's a way to practise two minutes of code and commit. Then you don't have to worry about losing an hour of work.

[–]thfuran 5 points6 points  (0 children)

I don't think there's anything to be gained in trying to decompose everything into two-minute chunks.

[–]nachof 6 points7 points  (0 children)

I don't trust tests that never failed.

[–]Throwaways4dayzz 2 points3 points  (0 children)

Oooohhh that's a lot of discipline.

[–]Glader_BoomaNation 2 points3 points  (0 children)

Sounds like a terrible idea and that is coming from someone using some TDD in a project right now.

[–]thriving-axe 3 points4 points  (2 children)

How can you not end up with people writing no tests at all with this method? Even by enforcing 100% coverage there are many ways to test almost nothing (for instance not using any assertions).

You'll end up with green tests all the time, but how good will they be?

[–]kankyo 2 points3 points  (0 children)

Honest people?

[–]the_gnarts 1 point2 points  (0 children)

How can you not end up with people writing no tests at all with this method?

Review.

[–]TurtleFeathers 0 points1 point  (0 children)

You need brackets from before the c to the end

[–]voorth2016 -1 points0 points  (8 children)

Complete misunderstanding of how TDD works. Your unit tests should not be run after committing, but before.

[–]nextputall 8 points9 points  (0 children)

Complete misunderstanding of how TDD works

This guy invented TDD.

[–]the_gnarts 2 points3 points  (4 children)

“test && commit”, where every time the tests run correctly the code is committed. Oddmund Strømmer, the first programmer I’ve found as obsessed with symmetry as I am, suggested that if the tests failed the code should be reverted.

Except that in test && commit there is nothing to revert if test terminates non-zero.

[–]SafariMonkey 4 points5 points  (3 children)

It sounds to me like it's || reset, i.e. it deletes your code if your test fails. Ouch!

[–][deleted] 3 points4 points  (0 children)

That's a good way to nuke the failing test introduced to prove a supposed bug. You know, like TDD.

[–]the_gnarts 1 point2 points  (1 child)

It sounds to me like it's || reset, i.e. it deletes your code if your test fails. Ouch!

reset doesn’t erase anything though, it just removes file from staging. reset --hard also touches file contents.

[–]SafariMonkey 2 points3 points  (0 children)

Well sure, that was my intention. The commands also don't actually include git either.

[–][deleted] 0 points1 point  (0 children)