News for hackers. Stuff that matters.
Re:Giving up on test-first development by ekidd on Friday March 18, 2016 @06:24AM (#11310852)
From the article: Because you want to ensure that you always pass the majority of tests, you tend to think about this when you change and extend the program. You therefore are more reluctant to make large-scale changes that will lead to the failure of lots of tests. Psychologically, you become conservative to avoid breaking lots of tests.

Interesting. I've often found that the lack of tests leaves me absolutely terrified of making changes to large Ruby and JavaScript applications. I mean, if a test breaks, then I get a nice message right on the spot. But if I don't have tests, then the application itself breaks, and I may not find out until it's been put into production on a high-volume site or shipped to users.

Once an application crosses, say, 25,000 lines of code, it's hard to keep an entire program in my head, especially in a dynamic language and with multiple authors working on the code base. Under these conditions, large scale refactorings or framework upgrades can cause massive test failures, but the only alternative is to cause massive, unknown breakage.

Re:Giving up on test-first development by BonsaiDen on Friday March 18, 2016 @07:01AM (#11310967)
One good way to the limit breakage in such cases is to solely perform black box tests on the API level. In case of our Node.js based Backends we don't ever write a single classical unit test, instead we have a custom Framework built on top of Mocha which performs tests on the HTTP layer against all of our endpoints.

This works remarkable well in practice and allows for large scale refactorings under the hood with little to no impact on the tests. We can also mock databases, memcached, redis and graylog on their respective http/tcp/udp level. This in turn means no custom build mocks which could break when refactoring. The tests itself also contain no logic, they are pretty much just chained method calls with data that should go in and an expected response that should come out, along with a specification of all external resource our API fetches during the request and their responses etc. Any unexpected outgoing HTTP request from our server will actually result in a test failure.

As for scaling this approach, from our experience it works quite well, especially when you have lots of complicated interactions with customer APIs during your requests since the flows are super quick to set up.

Re:Giving up on test-first development by crdoconnor on Friday March 18, 2016 @08:01AM (#11311172)
That's the main reason I wrote this framework (mainly focused on Django for now, but able to much more than that):

http://hitchtest.com

I took this approach on several different projects, but I figured that a lot of the boilerplate/infrastructural code that you need to actually write these kinds of tests is poor or simply not available.

For example, declaratively starting and running multiple services together, in parallel and at the right time (with service dependencies) and printing their logs out.

Or, mocking the forward passage of time. (click something -> move forward a week -> click something else).

Or, asynchronously 'listening' using epoll for emails on a mock SMTP server that logs out the emails it receives.

Selenium's good for the web interaction stuff, but you need much much more than that to be able to effectively test at this level.

I think this kind of testing would be much more widely used and effective if the tools available were up to scratch.

Re:Giving up on test-first development by kayoone on Friday March 18, 2016 @08:45AM (#11311363)
I'd say do both. Unit tests often help me to make my code more readable/decoupled and also help to spot potential problems early on. They also act as a kind of abstract documentation for how things are supposed to behave/work. But functional/integration tests are what matters most in terms of being confident of deploying big changes because you can ensure that all the endpoints that are actually consumed by clients work as they should, but it doesn't help too much with spotting problems on the code level.
Re:Giving up on test-first development by BonsaiDen on Friday March 18, 2016 @09:20AM (#11311562)
For smaller projects I definitely agree with having both unit and integration tests, especially for libraries. One thing to look out for is the fact that you can always "cheat" in unit tests, e.g. you can be "lazy" and set up some internal state directly in the test to skip huge amounts of initialization, this of course becomes a problem when there's no actual integration test for making sure that the exact state can also be triggered from the outside when using the API. In my experience, ensuring that these cases are always covered can become pretty complicated once the project grows.

In our special case we have about 100 different endpoints all versioned and all dependent on multiple endpoints from the (rather badly documented) APIs of our customer. Most of the work our API does is spent combining / enriching the customers data and performing integration across the subresources. Setting up individual mocks for every single on of these complex requests flows manually is pretty much impossible at this scale.

So doing black box testing and enforcing a 100% test coverage (best for avoiding dead code) helps keeping us sane. In the end we don't care so much about how the implementation behind our HTTP response looks as long as we return the correct data in the end. The code itself still has to look good though :)

Re:Giving up on test-first development by kayoone on Friday March 18, 2016 @12:32PM (#11312887)
yeah, well you just test what you own anyway, for other stuff you could just grab some kind of dummy response and use that for testing your manipulation of that data, but of course you have to trust your customers endpoints to return the data in the correct format because that is out of your control.
Re:Giving up on test-first development by hinkley on Friday March 18, 2016 @05:55PM (#11315495)
Trust, but verify.

We've always found that writing your own smoke tests for the other guy's code saves a lot of head scratching and the game I like to call Blame Tennis, when each side insists that any new problem must be in the other side's stuff because surely WE haven't broken anything.

Re:Giving up on test-first development by jacques_chester on Saturday March 19, 2016 @11:56AM (#11318975)
These have become known in Pivotal as "frenemy tests". Poke a remote API to see that a) it is running b) it hasn't dropped a world-stopping change.

Typically run as a pre-build sanity check when you have remote integrations.

On some Labs projects we've written extensive request tests and stub services based on documentation, then handed those to the upstream service. Usually there is some angst at this point, being the first time that any kind of TDD suite has turned up to ask awkward questions.

Re:Giving up on test-first development by hinkley on Saturday March 19, 2016 @09:17PM (#11321329)
I still maintain F5 owes me a job. I did QA for them for a year back in the dot-com boom. The first couple of versions of BigIP didn't really support session affinity, despite being the flagship feature. I think we filed something like 6-8 pretty big bugs, all in different parts of the code.

Sadly, despite not working, they were still about 4 years ahead of their competitors.

Re:Giving up on test-first development by czardoz on Friday March 18, 2016 @12:01PM (#11312654)
This is exactly why we created Newman (https://github.com/postmanlabs/newman/). Hitting every endpoint of our API gives enormous confidence when deploying it to production.

(Disclaimer: I work on Newman as a part of my day job)

Re:Giving up on test-first development by cousin_it on Friday March 18, 2016 @07:41AM (#11311090)
Yeah, I mostly prefer end-to-end tests as well. Though to be fair, they are often slower than unit tests, because you need to start up the whole system. And they are worse at pinpointing problems, though that doesn't seem to be a big deal in practice.
Re:Giving up on test-first development by schrodinger on Friday March 18, 2016 @10:15AM (#11311898)
I like to test the whole system via end-to-end tests, as they're the best bang for the buck. And then I'll create unit tests for more algorithmic code, like a parser, sort algorithm, shortest path calculator, financial calculations. Those also tend to require the least amount of test context setup, making them less painful to write.
Re:Giving up on test-first development by hinkley on Friday March 18, 2016 @05:59PM (#11315524)
I have almost always worked for customers who enjoyed changing their minds arbitrarily and often in ways they swore they would never do.

In the face of grossly changing requirements, I've never had much luck keeping E2E tests up and functioning properly. And people have a bad habit of investing more time and energy than a particular test is worth in trying to keep it working or porting it to the new requirements.

Unit tests are cheap. If the requirements change invalidates twenty of them, you just delete them and write new ones. Easy.

Re:Giving up on test-first development by BonsaiDen on Friday March 18, 2016 @08:02AM (#11311180)
I in part agree with the pinpointing, though in my experience this really boils down to an issue of scope and how much of the data you want to test in each of your tests. E.g. an API returning user data, do you have one test for the whole set of data or one test per field.

For our use case we have some pretty "fancy" deep-equals logic for nested structures and allow to specific fields as "to be ignored" in our test expectations.

When it comes to speed, the most important part is to cut out everything you don't need, for us this means that our testing framework completely throws away the internals of Node.js HTTP layer. We never create a single TCP socket in our tests, which gives an incredible speed up. As a bonus this also allows to test timeouts and low level HTTP errors in < 1ms, since we can just return the timeout directly from the low level APIs and Node.js will invoke the timeout event on the http client handle.

> Running "noir:mock" (noir) task > ...................................................... > 1048 passing (10s)

And yes, that really reads 10 seconds and yes I always get a bit bored when I have to run the tests for one of our Django backends, feels like an eternity... :)

Re:Giving up on test-first development by maccard on Friday March 18, 2016 @11:36AM (#11312442)
Count yourself lucky that your test takes 10 seconds. A partial build on my project takes ~3 minutes to compile + link. A full build is about 3 hours for everything.
Re:Giving up on test-first development by MaulingMonkey on Friday March 18, 2016 @12:15PM (#11312739)
I recently cut some link times from 3 minutes to 14 seconds by switching linkers (from bfd to gold doing Android dev.)

...sadly that's still only for a single project x config x arch combination. I still need to play around with incremental linking options that appear off by default...

Re:Giving up on test-first development by hinkley on Friday March 18, 2016 @06:11PM (#11315609)
I had a build that took 25 hours to run once. Never again. The only reason we got any work done is that we ran a 1, 3 and 19 hour part of it in parallel. But I really just wanted to throw out the long part (bad E2E tests) and start over.
Re:Giving up on test-first development by edwinnathaniel on Friday March 18, 2016 @01:21PM (#11313316)
> though that doesn't seem to be a big deal in practice

Gotta be careful there chief. In practice is usually refers to "your experience" (but might not be mine).

My experience is on the flip side: end-to-end tests are super slow due various reasons...

Re:Giving up on test-first development by endemic on Friday March 18, 2016 @12:29PM (#11312856)
Functional tests are the best kind of tests. While unit tests are nice sanity checks when implementing tricky methods, when the rubber hits the road, you want to know if the whole app works as you expect it to.
Re:Giving up on test-first development by spinlock on Friday March 18, 2016 @11:12AM (#11312289)
Of your tests break when refactoring, something is wrong. Probably, you're testing the implementation not the behavior.
Re:Giving up on test-first development by icebraining on Friday March 18, 2016 @12:11PM (#11312713)
The behaviour of internal components is part of the implementation of the whole application.
Re:Giving up on test-first development by msbarnett on Friday March 18, 2016 @03:39PM (#11314318)
In my experience, for any non-trivial application with a non-trivial number of tests, some percentage of those tests, particular the unit tests, will have by accident or carelessness come to rely on internal implementation details that aren't reflected in the result.

Those kinds of "atrophied" tests can make a refactor considerably more painful than it should be.

Re:Giving up on test-first development by enraged_camel on Friday March 18, 2016 @10:44AM (#11312096)
Yep. In other words, test the result, not the implementation.
Re:Giving up on test-first development by raverbashing on Friday March 18, 2016 @07:31AM (#11311057)
This is a good idea, hence, expect hate from TDD purists
Re:Giving up on test-first development by rhizome on Friday March 18, 2016 @04:37PM (#11314784)
Can you say that API black box tests are strictly denoting "what" is broken, while unit and functional tests would tell you "where?"
Re:Giving up on test-first development by sago on Friday March 18, 2016 @06:43AM (#11310908)
It's not a good argument against testing, I agree. Automated testing is a huge boon for software quality (though by no means a panacea).

But TDD, in my experience, gives a slightly different dynamic. Because you generated the code being motivated by the tests, there are a lot of unit tests that don't test functional units - tests that are essentially testing implementation decisions.

I've seen situations where that big refactoring would involve scrapping or rewriting tests, and that causes its own kind of architectural conservatism.

I ended up in a compromise position. I use a lot of tests, but I only do TDD in niche cases where it suits the problem I'm solving.

Re:Giving up on test-first development by ncphillips on Friday March 18, 2016 @07:10AM (#11311000)
> Because you generated the code being motivated by the tests, there are a lot of unit tests that dot test functional units - tests that are essentially testing implementation decisions.

I've seen this happen to myself numerous times as well, but I don't think this is good argument against TDD.

If a tests fails because the implementation details change, that tells us that we wrote a bad test, not that TDD is bad. As I get better at writing tests, I am better able to catch these kinds of errors ahead of time. There are a ton of little techniques you can use and questions you can ask yourself about your code that can make your tests better.

Furthermore, test code is just as important as production code, and we should be just as ruthless in refactoring and peer-reviewing each others tests (within reason).

TDD is NOT suitable for every problem, this is true. But I think too many people give up on it because they see "the problems of TDD" which are actually just "the problems of writing bad tests".

Note: I'm not trying to target you sago, but merely making a general observation. I'm talking more about people who don't write tests even close to the time of writing the code, or don't write any tests at all because the their tests kept breaking for no good reason and were slowing them down.

Re:Giving up on test-first development by sago on Friday March 18, 2016 @07:26AM (#11311043)
> that tells us that we wrote a bad test, not that TDD is bad

I strongly disagree. The only thing that matters to how software works for an end user is its boundary. You simply can't do TDD by only testing the boundary.

You have to write a test before each unit of code, so you have to test those internal interfaces, the way units of code work. But that is exactly the stuff that should be allowed to change. It's a mistake to assume 'implementation details' only exist within a function. That stuff you can avoid testing, but the behavior of the function is itself an implementation detail for whatever is using that function.

I simply cannot imagine TDD for anything other than a toy example where you don't end up writing tests that depend on the software's implementation, and are therefore inertia to changing that.

> we should be just as ruthless in refactoring and peer-reviewing each others tests

I strongly agree. But this is rarely part of the TDD ethos. Saying "I refactored the code and threw away 100 tests." is likely to send TDD folks twitching, in my experience.

Re:Giving up on test-first development by RHSeeger on Friday March 18, 2016 @08:57AM (#11311442)
> The only thing that matters to how software works for an end user is its boundary.

You're ignoring the fact that tests aren't only to validate "end user functionality". They're also there to make life easier for the developer; to make both initial development and maintenance easier.

If I need a custom sort algorithm for my product, I'm going to write unit tests for it's implementation. I'm also going write functional tests to make sure the end user is seeing things sorted. However, those tests serve different purposes.

The unit tests allow me to write clean, simple tests that show exactly what the implementation is supposed to be doing for different inputs. That allows me to change the implementation of the sorting algorithm later and worry less about breaking the functionality.

The functional tests are (generally) not going to be as clean and obvious, nor cover every possible partition of inputs that the implementation could get.

Re:Giving up on test-first development by sago on Friday March 18, 2016 @09:48AM (#11311727)
> You're ignoring the fact that tests aren't only to validate "end user functionality".

Erm, no, that was my entire point!

Re:Giving up on test-first development by RHSeeger on Friday March 18, 2016 @10:03AM (#11311822)
Wow... um... you're right. I was flitting around and dealing with external communication at the same time; you have my apologies.

I think my points align pretty well with what you were saying instead of against it.

Re:Giving up on test-first development by sago on Friday March 18, 2016 @10:27AM (#11311966)
Thanks for the response, it's fun to read someone strongly disagreeing while saying what you think. slightly baffling, but fun ;)
Re:Giving up on test-first development by agentultra on Friday March 18, 2016 @11:29AM (#11312398)
> If I need a custom sort algorithm for my product, I'm going to write unit tests for it's implementation.

I would start with writing an assertion about the end state of the sort. Then using syntactic substitution of the predicate calculi derive the program by assertions.

I'd then have a specification of the algorithm as a mathematical model from which I can check every possible execution for the entire domain on the sort. If I'm so inclined I would have a good basis for a proof.

The unit tests then become assertions on the implementation and don't have to verify correctness.

It would be awesome though if I could just generate the code directly from the specification!

Re:Giving up on test-first development by jkaptur on Friday March 18, 2016 @02:27PM (#11313777)
You would? Can you demonstrate how that would work for, say, a sort algorithm with a tunable "fuzziness" parameter? Informally, after the algorithm is complete, each element is within k indices of where it would be after a traditional sort. So k=0 could just be quicksort, but as k approaches the length of the input we have to do less and less work.

It's easy to dream up algorithms and traditional unit tests for this (and easy to see how the large input space makes the approach suboptimal). I'd love to see how your approach would work.

Re:Giving up on test-first development by MichaelBurge on Friday March 18, 2016 @08:38PM (#11316516)
Would you actually do this, or do you just like to imagine a world where people do this?

I'm familiar with Coq and Prolog(one of which I think you're hinting at), but I'd reach for Perl or C over either one if I needed to write a trading program or generate a statement from my accounting software or something.

Re:Giving up on test-first development by agentultra on Monday March 21, 2016 @12:30AM (#11326249)
I learning to use these techniques in my everyday work (cloud software).

I think of it like this: nobody is going to care if I screw up the script to balance my accounts. If I write some software that messes up the balance of everyone's account in some bank then someone is going to care.

I don't think formal methods and rigor are the sole domain of government institutions, avionics control software, and industrial robotics. The public relies on the cloud and the applications that run on it and they have no recourse if their data is exposed or disappears.

Imagine if instead of crossing over a bridge you were stopped at a booth and asked to sign a wager stating that nobody is liable if the bridge collapses underneath you while you cross it. Rich or poor, regardless of how much you pay in taxes, you should be able to rely on that bridge being built to the highest standards we know how and someone should be liable if it falls down. You can rely on this in real life. Why do we not have this for software?

I'm not saying I write all of my software using formal methods and rigorous proofs. It's often good enough to sketch my idea on the back of a napkin when I'm building a tool shed. But nobody built a sky-scraper without doing a little math and being fairly rigorous in their thinking.

Re:Giving up on test-first development by oldmanjay on Friday March 18, 2016 @10:05AM (#11311840)
I have used TDD to construct many production systems. Your lack of imagination is not a particularly compelling basis for an argument.
Re:Giving up on test-first development by sago on Friday March 18, 2016 @10:31AM (#11312002)
You're disagreeing with my 'I can't imagine'? So you're saying you've built non-toy systems with TDD where you've never tested anything but the user-facing behavior of the system?

I'd be interested in knowing how, and what kind of thing you build. I can almost imagine it for an API or framework, where almost every implementation choice is on the boundary. But even then, you have to test private functions to do TDD, surely.

I work on real time stuff, and in that stuff, the user-facing functionality is hard to test, and usually not tested in a TDD kind of way. The TDD stuff is all internal.

Re:Giving up on test-first development by mbrock on Friday March 18, 2016 @08:18AM (#11311240)
Changing tests is work, yes. Unit tests are precisely about verifying implementations, and maintaining them is the price you pay for having these layers of verification. It's inertia in the way a safety net is a barrier.
Re:Giving up on test-first development by hinkley on Friday March 18, 2016 @06:09PM (#11315597)
I have always found the 'safety net' analogy uninspiring, and people who think they're tough and manly don't need safety nets, thankyouverymuch.

Now, safety equipment in a race car is something else entirely. Half of it keeps you from dying immediately on impact, sure, but the other half actually lets you go faster. The 5 point harness, for example, helps keep you from losing control of the vehicle during high G maneuvers, by keeping your torso in the seat and therefore your legs and arms in (roughly) the correct orientation to the steering wheel and the pedals.

Re:Giving up on test-first development by firepoet on Friday March 18, 2016 @08:35AM (#11311313)
Not this TDD folk. :-)
Re:Giving up on test-first development by geoelectric on Friday March 18, 2016 @05:12PM (#11315087)
I come to this from a test/automation engineering background and I'd like to amplify your last point.

There are a couple things to consider that sometimes become taboo in orgs--but shouldn't.

The first is that you don't need to test everything. I recommend having a great set of those API-level black box tests as an acceptance suite, but at a component or unit level you should pick your battles. If you'd architect for DI -only- to test, that testing had better be pretty necessary, otherwise you introduced complication (and risk) without a lot of benefit. That risk can actually overwhelm any benefit of testing.

The second is that you should absolutely scrap tests of implementation details at the point that the implementation becomes a black box. Tests are like scaffolding during construction, and we don't leave the scaffolding up when the building is done--we do inspections of the building instead. The same mindset should be applied to testing. Different phases need different tests, and too many tests at too low a level of abstraction absolutely cause maintenance and flexibility issues if you're not willing to let them go.

But that's no reason to back off entirely. SOME things need to be unit- or component-tested SOMETIMES. Those things generally benefit from TDD.

It's all about making intelligent decisions. There's a sometimes-controversial movement in QA/test called "context-driven testing" which comes down to there are very few always-best practices, and strategy should be tailored to your problem and situation--not done by rote, book, or prior (read, your boss's or CTO's) assumptions of what's always right. Otherwise you tend to get something more onerous than useful.

The considerations around that approach apply at the low-level test tier as well.

Re:Giving up on test-first development by crdoconnor on Friday March 18, 2016 @07:36AM (#11311073)
>I've seen situations where that big refactoring would involve scrapping or rewriting tests, and that causes its own kind of architectural conservatism.

I call this test concreting:

https://hitchtest.readthedocs.org/en/latest/glossary/test_co...

The way to avoid it is to either be damn sure that the API you've surrounded is tight, clean and unlikely to need to change much or to test at a higher level.

Re:Giving up on test-first development by atemerev on Friday March 18, 2016 @07:37AM (#11311075)
> tests that are essentially testing implementation decisions.

There shouldn't be any. Those are not useful at all.

Re:Giving up on test-first development by sago on Friday March 18, 2016 @07:52AM (#11311132)
See my reply above. I think your view is either naive, or you understand 'implementation decision' in too narrow a way.
Re:Giving up on test-first development by atemerev on Friday March 18, 2016 @08:18AM (#11311238)
I understand "implementation decisions" in quite well-defined way; only functional invariants should be tested. Your example is a perfect illustration for one.

Additional point is that invariant-based testing can easily be transformed into automated fuzzy tests using Quickcheck and its analogues, and this can find immense amount of otherwise hidden bugs.

Re:Giving up on test-first development by sago on Friday March 18, 2016 @09:57AM (#11311783)
> only functional invariants should be tested.

That makes no sense at all.

> Your example is a perfect illustration

I didn't give an example.

> invariant-based testing can easily be transformed into automated fuzzy tests

'fuzz' not 'fuzzy'. True, but irrelevant to the point being argued.

Re:Giving up on test-first development by maxxxxx on Friday March 18, 2016 @11:43AM (#11312500)
"I've seen situations where that big refactoring would involve scrapping or rewriting tests, and that causes its own kind of architectural conservatism."

Yes, rewriting tests is part of a refactor. You always have to be willing to do that or just scrapping outdated tests.

Re:Giving up on test-first development by ivanhoe on Friday March 18, 2016 @06:54AM (#11310946)
From what I understand author is not questioning the usefulness of testing, just TDD approach of writing tests first. I personally prefer a sandwich approach, I start with code first, and then write tests for it as soon as I have that little piece of logic finished (usually a method or two). Then I add more code, followed by more test, and so on. Works great for me and my team.
Re:Giving up on test-first development by drewhk on Friday March 18, 2016 @07:49AM (#11311117)
I nowadays do an approach where I don't write tests first, but I write down the test titles (I use a language where the testing framework gives a nice DSL to write nicely readable test names compared to method names) and I just mark them as pending (which will report as no test failures or passes but ignored cases). I rarely end up with the same test ideas and names which I started from, but since I only start with names which do not hinder refactorings this worked out surprisingly nicely for me.
Re:Giving up on test-first development by hsitz on Friday March 18, 2016 @01:30PM (#11313380)
My impression, too, the author explicitly says he understands value of unit testing and will continue to do it, but he's going to give up on the idea of writing tests before he writes the actual program code. Strange, from what I can tell 90+ percent of comments in this thread treat the author as if he said he was giving up tests entirely.
Re:Giving up on test-first development by atom-morgan on Friday March 18, 2016 @08:55AM (#11311430)
I agree. If people started viewing coding as an art instead of a strict science I think people would feel more comfortable doing something like this instead of a strict Test First or Test After.
Re:Giving up on test-first development by hinkley on Friday March 18, 2016 @05:41PM (#11315361)
See, I find the reverse to be true.

I too don't have the disposition to patiently wade through fixing tons of tons of broken tests over and over again. IF I have to I can do it, but I know better than to unreservedly trust my judgement about how things are progressing.

But what this has taught me is to stop trying to push water uphill. If testing is hard because of questionably coupled code, refactor it NOW instead of waiting for things to get bad. The refactoring almost always suggests new features we could add to the code (or makes me backpedal on pronouncements that certain things were 'impossible'), and the number and kind of tests that break is reduced.

I came across a quote recently from Bertrand Meyer (the Design By Contract guy), where he suggested that code for making decisions and code for acting on those decisions should be separated. I found myself nodding along to this because it was something I knew intuitively but had never articulated: Decisions without actions don't need mocks, and actions without decisions need at most one or two (often none). Decisions can be tested (possibly in parallel) with unit tests, and actions tested with functional tests. Then all your integration testing is that decisions lead to actions (basically that event dispatch works) and that catastrophic failures are handled gracefully. A proper testing pyramid.

Now I want to figure out which of his books or interviews this was in because I want to read the rest of what he had to say on the subject.

Re:Giving up on test-first development by Ensorceled on Friday March 18, 2016 @08:26AM (#11311271)
That's different, I'm against TDD for the same reason the author is. I'm FOR automated testing for exactly the same reasons you are.

Think of it this way: pre-testing makes you afraid to change you mind because you throw out your tests, not post-testing makes you afraid to change your mind because you might break something. If you think changing your mind is good the path forward is clear.

Re:Giving up on test-first development by catnaroek on Friday March 18, 2016 @10:54AM (#11312162)
> Under these conditions, large scale refactorings or framework upgrades can cause massive test failures

An even bigger problem is that large scale refactorings can result in the tests themselves no longer being correct (which isn't the same thing as “not passing”), if you test at too fine a level of granularity. However, when you wrote these tests, you couldn't have possibly foreseen a large scale refactoring 18 months into the future, so how do you tell in advance what the right level of granularity for your tests is?

Re:Giving up on test-first development by kazagistar on Friday March 18, 2016 @10:54AM (#11312166)
When tests function as a type system as well, this is true. Buy a good type system will guide refactoring and a good module system and IDE and will guaretee isolation .
Re:Giving up on test-first development by Illniyar on Friday March 18, 2016 @06:40AM (#11310899)
To be fair the author was abandoning TDD not tests. He explictly said that he'll add tests after he writes the code.
Re:Giving up on test-first development by organsnyder on Friday March 18, 2016 @06:57AM (#11310957)
Perhaps the author is more disciplined than me, but I'd have an extremely hard time actually following through and writing tests after-the-fact. After the code is "done", it's hard to keep working on it—no matter how much the "extra" work is needed.

I find tests to be extremely helpful for designing APIs. I write tests to enforce the contract my API is making with its consumers. Therefore, TDD forces me to consider the API from the user's perspective, rather than designing an API based on implementation details. That also helps to cut down on the cost of refactoring—unless I'm making an API-incompatible change, my tests should keep passing. This gives me more confidence as I'm refactoring, allowing me to make more sweeping changes.

Re:Giving up on test-first development by Ensorceled on Friday March 18, 2016 @08:23AM (#11311261)
You just need an accountability buddy. I do code reviews for my team and reject any pull request with insufficient test coverage.
Re:Giving up on test-first development by Retra on Friday March 18, 2016 @09:58PM (#11316839)
That works well when your API is small and understood. But when you're exporting someone else's results (e.g., returning the result of a floating point operation,) your tests could start to become so exacting that they are more difficult to write and less reliable than the code you're testing itself. In that case, writing tests is basically writing an ad-hoc waterfall-style software specification.

I tend to write tests when I'm not confident in the implementation or when the tests are trivial to write. At least, that's how I do it for new developments. If you're releasing code that people are relying on, you should have a whole suite of user tests and regression tests.

Re:Giving up on test-first development by pkolaczk on Friday March 18, 2016 @11:55AM (#11312600)
This is a great way to create APIs that are hard or nearly impossible to implement properly or efficiently. I can imagine how this could easily lead to horrible API design like a well-known stdlib `gets` function. From the user perspective, gets is a perfectly fine function. Unfortunately there is no way you could write a safe implementation, because in C you have no way of checking arbitrary buffer size. Low level implementation details do affect how we design APIs.
Re:Giving up on test-first development by adrianN on Friday March 18, 2016 @07:13AM (#11311009)
If one test breaks you get a nice message. If 20% of your tests break because they depend on functionality that you just changed intentionally, you increased the cost of your feature a lot.
Re:Giving up on test-first development by quaunaut on Friday March 18, 2016 @11:20AM (#11312341)
I don't really see how?

If you changed that functionality intentionally, then the other things it interacts with will require a change regardless. Furthermore, if it's that small of a change(as usually, the smallest changes are the ones that impact the most tests), it usually doesn't require any change to the test, aside from adding/subtracting a parameter or something.

Major functionality changes should carry weight. It's like saying that a motorcycle runs so much faster without a person on it- it defeats the purpose.

Re:Giving up on test-first development by plinkplonk on Friday March 18, 2016 @07:31AM (#11311061)
I suspect the author of the article is only giving up on test first or test driven development where you write tests before writing each bit of the program. I doubt he is against having a corpus of tests for your program.
Re:Giving up on test-first development by mikehollinger on Friday March 18, 2016 @10:08AM (#11311860)
Agreed. I'd argue that if a large number of tests break when a "large" change occurs in an application, those tests are either testing the wrong thing, or written with bad starting assumptions. Yes, there's a transitional period where the responsibility may shift from the caller to the call-ee to take care of some resource, and yes, stuff will break, but the amount of test breakage should be proportional to the impact to the application.

I greatly-prefer the warm fuzziness of knowing that I have a large number of unit tests as a "safety net" to detect if my own thoughts on what is "correct" are in some way wrong.

Re:Giving up on test-first development by josephlord on Friday March 18, 2016 @09:16AM (#11311533)
I think the language and in particular the type system matters a lot. So making big changes in the absence of tests in a Swift or even the somewhat more loosely typed Objective C is less scary than in Ruby and Javascript application.
Re:Giving up on test-first development by justicezyx on Friday March 18, 2016 @02:25PM (#11313765)
I concur your feeling.

In my observation and feeling, the statement: " Because you want to ensure that you always pass the majority of tests, you tend to think about this when you change and extend the program. You therefore are more reluctant to make large-scale changes that will lead to the failure of lots of tests. Psychologically, you become conservative to avoid breaking lots of tests."

is most likely due to the low quality and low test coverage of the exiting code base. So that the tests are fragile, seemingly hinders changes.

If things are started with TDD, I would be really surprised that tests hinders change.

Re:Giving up on test-first development by mamon on Friday March 18, 2016 @11:15AM (#11312304)
Ruby and Javascript are dynamic languages, so you need all those tests to make up for missing compiler type checks. With staticaly typed languages like Java or Scala things are much different.
Re:Giving up on test-first development by iamleppert on Friday March 18, 2016 @04:01PM (#11314495)
Don't expect just because there are no test failures that you haven't broken anything. I can't stand developers who have this mindset.

Just because there are unit tests, doesn't mean they are covering all the code foremost, or that they are written properly to truly detect when things have changed for the worst.

Tests are not a replacement for actually testing and verifying your changes in whatever application gradient you're working in.

Re:Giving up on test-first development by vannevar on Friday March 18, 2016 @03:24PM (#11314217)
While I understand that the conservatism the author refers to might be detrimental to the individual working alone, in a team environment it is actually an advantage. The module the team member is working on is likely a dependency for some other team, and any test-breaking refactoring---however beneficial it might seem---needs to be conscientiously approached and coordinated with other people. There may be very good reasons not to pursue refactoring at the moment, reasons that an individual narrowly focused on the module at hand might not be aware of.
Re:Giving up on test-first development by choward on Friday March 18, 2016 @12:35PM (#11312924)
> I've often found that the lack of tests leaves me absolutely terrified of making changes to large Ruby and JavaScript applications.

I agree. If I'm working on some part of the app that doesn't have any test coverage, I might add some high level tests before I start.