Hacker News new | ask | show | jobs
by BeetleB 1464 days ago
> It's easier conceptually go to 'up' the testing tree from unit tests to E2E tests, than it is to come down.

It all depends on the language and the project, but my experience is usually the opposite. It's often much easier to write an end to end test. To be able to write a unit test you usually have to architect the code to make it easy to mock, etc - and that takes significant skill for most real world projects.

E2E tests have a lot of downsides, but being challenging to write is probably not one of them.

1 comments

I took it as: if you only have E2E tests then retrofitting unit tests is hard.

My experience agrees with this. Adding unit tests to untestable code (think: class has 10 dependencies that it news up being the first branching of a depdendecy graph to be untangled) requires refactors that just don’t get done with the busyness of other priorities.

> I took it as: if you only have E2E tests then retrofitting unit tests is hard.

That's been my experience. My point is that the reason the project has E2E tests and not unit tests is because it was easier to add E2E tests.