Earlier quoted context omitted.
> and they break more often than unit tests. That isn't my experience, unit tests breaks all the time and has to be rewritten from simple refactoring while larger tests pass as long as you keep behavior the same. This means that the bigger tests are way better for refactoring and safely making changes to your code. If most of your tests are unit tests and you don't have bigger tests covering the same things then refa…
If your unit tests are breaking all the time, try testing less at the unit level and more at the integration level. There are a lot of dogmatists out there who preach that unit tests should have "X % coverage" no matter what, but that's a ridiculous claim. Different projects will require different mixes of testing strategy, and part of the engineering process is arriving at your verification and validation methods, c…
The testing pyramid should look more like a crab
51–60 of 65 posts
Re: The testing pyramid should look more like a crab
#52> "And when we look at what Cypress allows you to do (which is write many useful tests that have very little flake) then you wanna write more end-to-end tests." Very little flake? That's not my experience with Cypress. The Cypress e2e tests on our build server sometimes fail for no discernible reason. Then you run them locally, and different tests fail, sometimes for understandable reasons (but then why didn't they f…
You'll probably be interested to hear that Cypress are... uhm... addressing this by adding "flaky test detection" and some amount of automatic retrying in v5.
We use Cypress at work, we have flaky test problems, but I'm not convinced much of it is actually Cypress's fault. As others have mentioned, writing front-end code to be testable by E2E is not necessarily straightforward, and when you're trying to add tests to a big existing codebase I think you kinda have to accept some flakiness and retrying.
What I've been wondering about recently though is: if you construct applications in a certain way do you still need real E2E tests? For example, React is declarative, and with a state-management system like Redux shouldn't you be able to get the same kind of assurance that E2E gets you without needing an actual browser? Maybe things like animations, visibility etc are where that comes unstuck?
Re: The testing pyramid should look more like a crab
#53All kinds of tests are needed, but I find the pyramid arises from the fact that there are a lot more low level units than high level behaviors.
Re: The testing pyramid should look more like a crab
#54By moving the 'meat' of the tests up high into the hierarchy, the author has just re-invented the testing ice cream cone with a different flavor. In software, we can make pretty much any process work for 18 months, before it starts to fall apart. If you don't stay at a company for at least a couple of years after they start doing testing in earnest, you won't really see that what you're doing doesn't scale/isn't resi…
This got so long I decided to split it in two: It is important to note you can't pull all of the tests down. I tend to use a plumbing analogy that I probably have stolen from the literature or a mentor - It's likely that QA already tested all of the pipes at the factory before they were installed in your house. But every plumber will turn on the taps and flush the toilet at once before they leave, to make sure the st…
You mostly use elaborate mocks for unit tests. There is much less need for mocking in integration tests.
Re: The testing pyramid should look more like a crab
#55Science Twitter: "Everything is crab." HN two weeks later: "What if testing were crab?"
Re: The testing pyramid should look more like a crab
#56> "And when we look at what Cypress allows you to do (which is write many useful tests that have very little flake) then you wanna write more end-to-end tests." Very little flake? That's not my experience with Cypress. The Cypress e2e tests on our build server sometimes fail for no discernible reason. Then you run them locally, and different tests fail, sometimes for understandable reasons (but then why didn't they f…
As I remember it Protractor was just a wrapper around WebDriver with some glue code to wait for Angular doing its thing after data changes. If you're using e.g. React or anything else that does not do dirty checking, you should still be able to use WebDriver. (That said, that's certainly still flaky enough.)
Re: The testing pyramid should look more like a crab
#57Earlier quoted context omitted.
Is that a benefit of end-to-end tests? Seems more like encouraging more unit tests would discourage bad coding habits if anything.
I don't find it does discourage bad coding habits. It just amplifies the problems they cause.
Re: The testing pyramid should look more like a crab
#58Earlier quoted context omitted.
I find that unit tests are much less useful than integration tests. When we write unit tests, we ask the person to write the code to spend a lot of work documenting how they expect the system that they are integrating with to work. What happens when that system behaves differently? Or changes in the future? And the way that mocks are set up are very sensitive to implementation details, which is a maintenance burden w…
If it's talking to the database, it's not a unit test. https://blog.metaobject.com/2014/05/why-i-don-mock.html
If it is talking to a database, it's not a unit test.
If you've mocked out the database, it is a unit test.
My point is that the unit test version is a lot of work to create and tends to be useless. (Which is similar to the point that your blog link made.)
Re: The testing pyramid should look more like a crab
#59Earlier quoted context omitted.
If it's talking to the database, it's not a unit test. https://blog.metaobject.com/2014/05/why-i-don-mock.html
I'm aware of this. If it is talking to a database, it's not a unit test. If you've mocked out the database, it is a unit test. My point is that the unit test version is a lot of work to create and tends to be useless. (Which is similar to the point that your blog link made.)
And since the point of an integration test is to test the integration, having a stubbed out version of that is fairly pointless, as you have discovered.
If you create actual unit tests, and allow those to drive your design, you will find much more joy.
Re: The testing pyramid should look more like a crab
#60Earlier quoted context omitted.
>If your code is well-structure You've alluded to the real benefit of end to end tests here, IMHO. They make very few demands about how your code is structured. This is fantastic if you've just been handed a big ball of mud. There is a definite trade off between faster running tests and tests which don't need to be rewritten every time you change some code.
Is that a benefit of end-to-end tests? Seems more like encouraging more unit tests would discourage bad coding habits if anything.
Good engineering is what creates good engineering. What you actually do, I suspect matters a lot less.