Live data from Hacker News

Most Unit Testing Is Waste (2014) [pdf]

rbcs-us.com

141–150 of 164 posts

Re: Most Unit Testing Is Waste (2014) [pdf]

#141
post #98

The thing is that most people don't understand that the code needs to be tested anyway. If you don't test it, you are just an idiot who has no proof that the code does what it claims to do. Now because you have to test it anyway, you can just simply spend the same time writing a unit test instead of executing the code with manually configured non-repeatable test cycles, a.k.a clicking through the UI, or sending Postm…

To add to this sentiment, tests also give teams confidence that is needed. It gives engineers confidence when developing new features because the test suite will break if you introduce a regression. It gives engineers confidence during deployment/CD. While the tangible benefits of unit tests are very important, there are other intangible benefits that are equally important.

What confidence do unit tests add that other kinds of tests do not?

The confusion here between unit testing and automated testing in general kind of illustrates the author’s point: we’ve become so obsessively focused on one kind of testing that we aren’t thinking critically about its alternatives (of which there are many others besides “no tests”).

Re: Most Unit Testing Is Waste (2014) [pdf]

#142
post #119

Earlier quoted context omitted.

?? sorry what do you mean, I was happily reading multiple types of logs with multiple different format records for a Billing system using statically typed PL/1G in the 80's Apart from both json and XML are a PITA to work with in the first place

JSON is wonderfully simple to work with - in a dynamic language. Having to map it to a statically known schema, as you would in a statically typed language, loses that simplicity and can be, as you say, a PITA.

I think that's a defect of JSON not statically typed languages.

Re: Most Unit Testing Is Waste (2014) [pdf]

#143
post #62

Earlier quoted context omitted.

Is it a waste to keep the test around until you're ready to switch to a more sophisticated type system?

A question, coz Im not sure I follow. How is type system (as described by wiki) supposed to test domain or functionality? Or are you talking here about completely different type system ?

What you can do with the type system depends on the language. It can't replace tests entirely, but it can usually make some more boring tests superfluous, and in more exotic languages the type system can be surprisingly helpful.

Re: Most Unit Testing Is Waste (2014) [pdf]

#144
post #119

Earlier quoted context omitted.

JSON is wonderfully simple to work with - in a dynamic language. Having to map it to a statically known schema, as you would in a statically typed language, loses that simplicity and can be, as you say, a PITA.

I think that's a defect of JSON not statically typed languages.

"defect of JSON" while it could be better, it has some type definitions and as I said, people are too deep in the static world to see outside of it

Re: Most Unit Testing Is Waste (2014) [pdf]

#145
post #133

Earlier quoted context omitted.

I agree entirely. The more tendency there is to push development as an "engineering" discipline, the more evidence based research needs to be used to solidify or disprove certain development dogmas repeated over and over again, which in many cases, seemingly have no empirical evidence beyond a few anecdotal success cases. This is the norm in the industry, "you're doing it wrong, the best way is this way..."--based on…

Is there a good way to fix it? I mean, if you were building bridges, certainly another engineer could show you data about material properties and successful builds, and you could reasonably extrapolate to your new (unique) design fairly well, but that's because you're building with the same physical materials and operating under the same laws. With software, it is a bit harder to find that common ground, because the…

It is actually simple. Just look into any business where safety and security matters.

I'm in automotive [0]. There is somebody who has to sign that the software is safe. Without someone to make that signature the car does not get released.

For Free Software, look at Sqlite. There are some nice slides from 2009 [1].

In general it results in some simple rules like "100% test coverage". Of course, these rules (while simple) are not easy to satisfy and certainly expensive.

[0] http://beza1e1.tuxen.de/aspice.html [1] https://www.sqlite.org/talks/wroclaw-20090310.pdf

Re: Most Unit Testing Is Waste (2014) [pdf]

#146

Earlier quoted context omitted.

What if most type system security is a waste? I don't personally believe this is the case, but I also can't tell you I know it to be false. What I do know is that types have a non-zero cost, and I think sometimes that's ignored, and only their benefits are acknowledged. But the efforts to bring types to historically dynamic languages show that not all common dynamic language idioms are amenable to reasonable type sig…

Apart from a bit more typeing up front I cant see many costs to typing.

That's because some of the cost you pay by changing the way you think so that it doesn't even occur to you to write programs that the type system won't like.

Re: Most Unit Testing Is Waste (2014) [pdf]

#147
post #89

Earlier quoted context omitted.

Surprisingly, the article doesn't engage with this argument! Unless I missed it, the author never mentions that unit tests can make refactoring other code easier. In my experience, after code is checked in, unit tests have two main purposes: 1. Checking that functions aren't completely broken in dynamically typed languages (i.e. a check so basic that a static type checker can do its job) 2. Allowing programmers to re…

I don't think I've ever seen unit tests that didn't need to be changed fundamentally to deal with any sort of refactoring more complex than extracting a function. Unit tests are supposed to work with the internals of a module and not just its boundaries. Since refactoring normally tries to significantly change the internals without changing the boundary, it usually also results in a rewrite of the unit tests. Integra…

I don't think I agree with your premise, but even if I take it as true--- it's the unit tests of the other modules that help me out, by ensuring I haven't managed to totally bust the module I'm working on.

Some people argue that a unit test of a module should mock out its dependencies and not rely on them. For unit tests like that... well, I endorse the article.

Re: Most Unit Testing Is Waste (2014) [pdf]

#149
post #79

Doing a typical "front-end" mobile application I write the following tests: * Integration tests that test the API I get a ton of value out of it though it's sometimes hard to guarantee a certain state at the API's end. But I use them while building the API's but they also can detect any kind of problem after an API upgrade etcetera * Unit tests that test data transformations This is stuff like date formatting, buildi…

I personally find testing incoming APIs a waste. Sometimes I write tests to verify that I treat the incoming data correctly if I transform it in fancy ways, but other than that, you should trust the API contract. It's almost like writing tests for the frameworks you're using. Granted, that's from a unit test perspective. Integration tests of APIs are invaluable. I wish we had them already where I currently work.

> but other than that, you should trust the API contract

As someone who's been working in corporate integration for the past 6 years..

Never trust a contract. Be in WSDL, OpenAPI spec, Word documents or otherwise. I've worked with large tech vendors, I've worked with finance, I've worked with large consultancies. The only people that seem to get it right, is the people you don't want to work with because it's soul-crushing - think HL7 et al.

Re: Most Unit Testing Is Waste (2014) [pdf]

#150
post #126
post #96

Earlier quoted context omitted.

Developers are expensive though. If dynamic languages let you write buggy code in half the time that it would take to write perfect code in a static language, that would be an acceptable trade-off in many contexts.

> If dynamic languages let you write buggy code in half the time that it would take to write perfect code in a static language, that would be an acceptable trade-off in many contexts. Shit at 50% off is still shit. You're not being paid to produce shit, even if you might be really, really efficient at doing so.

I assure you that many developers are being paid to produce shit.
Post reply on HN