News for hackers. Stuff that matters.
Re:What I wish I knew when I became CTO by crdoconnor on Wednesday February 14, 2018 @04:29AM (#16374624)
I think unit tests will die one day, and that day is probably not too far away.

These days I follow three "good practice" rules, all of which are violated when you follow common unit testing practise:

* Only put tests on the edge of a project. If you feel like you need lower level test than that then either a) you don't or b) architecturally, you need to break that code off into a different project.

* Test as realistically as possible. That means if your app uses a database, test against the real database - same version as in prod, data that's as close to prod as possible. Where speed conflicts with realism, bias toward realism.

* Isolate and mock everything in your tests that has caused test indeterminism - e.g. date/time, calls to external servers that go down, etc.

Re:What I wish I knew when I became CTO by akvadrako on Wednesday February 14, 2018 @10:12AM (#16376268)
> Only put tests on the edge of a project.

I mostly agree with your point, but I think this is too much. Projects should be made up of decoupled modules (units ?) with well-defined interfaces. These should be stable and tested, and mostly without mocking required.

The larger your project the more important this is.

Re:What I wish I knew when I became CTO by crdoconnor on Wednesday February 14, 2018 @12:25PM (#16377441)
>Projects should be made up of decoupled modules (units ?) with well-defined interfaces.

That goes without saying.

Nonetheless, if it's a very decoupled module with a very well defined, relatively unchanging interface which you could surround with tests with the bare minimum of mocking - to me that says that it probably makes sense to put it in a project by itself.

>The larger your project the more important this is.

The larger a project gets the more I want to break it up.

Re:What I wish I knew when I became CTO by ljf on Wednesday February 14, 2018 @07:24AM (#16375239)
While I personally believe in BDD and unit testing, I'm interested in some commentary here from down-voters - always keen to learn from examples
Re:What I wish I knew when I became CTO by crdoconnor on Wednesday February 14, 2018 @07:38AM (#16375309)
To be clear, while I'm a big fan of BDD the practise, I strongly dislike cucumber and other gherkin tools. I consider a large part of the relative unpopularity of BDD to be attributable to their problems.

I think the downvotes are largely dogma driven - people are quite attached to unit testing, especially for the situations where it worked for them and largely see them in opposition to "no testing" not a "different kind of test".