How do people here test their UIs? As an extreme example, the link here contains hundreds of lines of declarative code; a single typo (unclosed bracket, misspelled CSS property...) could break the site. So how is it tested? Probably it's not tested in any automated way, because manual testing (open the site and look) is much easier. Maybe lots of software is like that, to various degrees.
Superior Testing: Stop Stopping
31–40 of 55 posts
Re: Superior Testing: Stop Stopping
#32Regardless of all the arguments for and against tests, it's important to remember your purpose as an IT professional: Your job is to solve the customer's problem. That's it. HOW you solve their problems is entirely up to you, and some solutions will work better than others. The only thing about customers guaranteed to be consistent is that they will request changes. Some will be good changes. Some will be bad changes…
> but for 90% of projects, automated testing is the most efficient long term strategy I don't think this is a good way to think about it. I see plenty of projects that don't go anywhere, and I also see plenty of projects that do go somewhere, but where large parts change so little and are so easy to test manually that there's little point in much automation. Other parts are complex and full of contradictory business…
The problem is, regardless of how stable the code was, or how easy it was for the original author to test it manually, if the code hasn't been worked on for ages, then the original author is either gone or can't remember all the details of how it was supposed to work anymore. Which leaves you in a dangerous situation, because there's no good way of knowing which behaviors are by design and which ones are incidental.
Re: Superior Testing: Stop Stopping
#33The introduction made me hope for real advice on how to "stop stopping", but it only repeated the old arguments on why we want tests. Why not deal with some of the real problems that actually prevent people from writing automated tests? Real-world example 1: The system being developed talks to external system X. We don't want tests to litter the production database, especially since it's about accounting and we would…
If it's an accounting service, make a new account/table named "Software test". Book-keeping was invented to spot errors. If you have a non zero balance in your "Software test" account you probably have a bug in the software.
So now the balance in our "Software test" account is nonzero whereas it should be zero.
But audit requires us to record all bookings, so how do we explain these bogus bookings (both from the erroneous code that made the mistake in the first place, and from the manual adjustment later that fixes the mistake for the next test run)?
Re: Superior Testing: Stop Stopping
#34The introduction made me hope for real advice on how to "stop stopping", but it only repeated the old arguments on why we want tests. Why not deal with some of the real problems that actually prevent people from writing automated tests? Real-world example 1: The system being developed talks to external system X. We don't want tests to litter the production database, especially since it's about accounting and we would…
I'm currently working for an insurance company, where I created services that interact with legacy systems where you can't touch anything, because nothing can be deleted once in there. I had to submit a formal request for accounts and waited months for them. Once I had them, I had to wait weeks for having the right permissions set for those accounts. There are a test and a pre production environment, but they work differently from the production one, in very subtle ways. For example, the same account cannot login from two different places at the same time, while test and pre-production allow that behaviour.
Long story short: I've mocked the service completely, well just the parts I needed to interact with, and added assertions in my code that if something changes show an error message like "something has changed we're working on a fix" and send me alerts. I could not even get the team working on the legacy system send me an email before changing stuff...
But at least I can test my app and some of the tests are about checking that nothing has been updated in the meantime. They run automatically few times a day (just the checks) and warn me if something is wrong. Still better than a call from a user who usually can't explain what's wrong and you have to repeat the complete procedure on the phone, step by step.
Re: Superior Testing: Stop Stopping
#35I like the concept of error budgets. Start off by knowing what kind of quality and resiliency a system requires and design your test strategy around that. Means talking to the client about that. I'm not going to invest a load of time in various types of automated test for an internal site with a form over a database that 2 users use for low priority work. The idea of 80%-100% code coverage for basic work like that se…
If you have a client knowledgeable enough, then great. But most people who don't have an engineering background think that the correct number of bugs is 'zero'. It's really hard for them to get their head round something being - to some degree - buggy, and still being acceptable.
Re: Superior Testing: Stop Stopping
#36How do people here test their UIs? As an extreme example, the link here contains hundreds of lines of declarative code; a single typo (unclosed bracket, misspelled CSS property...) could break the site. So how is it tested? Probably it's not tested in any automated way, because manual testing (open the site and look) is much easier. Maybe lots of software is like that, to various degrees.
In flutter parlance, a whole view (page/screen) is a widget, and that's the granularity I was testing it - it's good for testing the high level patterns that the screen is meant to adhere to, e.g. Send button appears when there is some text to send.
You can also have golden images for rendering of each screen. They change a lot, but that at least forces developers to look at the changes each time and decide if they're on purpose.
Re: Superior Testing: Stop Stopping
#37You have to underbid the initial proof of concept phase to win it, and then hack together something that vaguely meets the requirements in the limited budget.
Then you've got the next 10 contracts over several years to develop that into the actual product - meet all the requirements. The problem is that nothing in this process encourages you to write good, clean code. If the code was such a mess that it took 3 times as long as it should to add new features, that meant that we could charge 3 times as many hours.
Re: Superior Testing: Stop Stopping
#38The introduction made me hope for real advice on how to "stop stopping", but it only repeated the old arguments on why we want tests. Why not deal with some of the real problems that actually prevent people from writing automated tests? Real-world example 1: The system being developed talks to external system X. We don't want tests to litter the production database, especially since it's about accounting and we would…
How would you manually test in a situation like that? If you can't interact with the production API because it would corrupt data, and there is no dev API, would you just be guessing that everything works before you deploy your code?
Re: Superior Testing: Stop Stopping
#39> It is the goal of every competent software developer to create designs that tolerate change [...] Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse. I agree that testing…
That being said, there is a certain degree of intellectual rigidity when it comes to TDD. The point of a good test suite is to capture the behavior of the product from a user perspective, and not to duplicate implementation details, or test the same behavior at three different levels of the architecture.
Ideally, each path in the code should be exercised by one [and no more] test written from the perspective of the product, but not necessarily using the user-visible APIs. To exemplify test refrain, suppose one is building an IDE. Write one test that the IDE frontend surfaces errors from the compiler to the user, and write a test suite for the compiler to check they produce sensible errors, using code coverage tools to make sure all possible errors are accounted for. But don't test each and every compiler error using the IDE frontend APIs.
Re: Superior Testing: Stop Stopping
#40I heard the "customers don't pay for tests" line recently, from someone boasting about how they migrated hundreds of thousands of lines of PHP from 5.x to 7.x. I didn't have an off-the-cuff reply to this, but thinking about it afterwards the issue became clear to me: customers don't pay for code either! Customers pay for solutions to their problems. I think the key phrase is "how do we know?": maybe those hundreds of…
> customers don't pay for code either! Customers pay for solutions to their problems. And that's why you don't test code. You test that your application comply with your customer's requirements. I'm happy to see things changing about tests with people realizing fine grained unit tests are often an hindrance and you should prioritize end to end testing. Test the interface of what you're selling, not the inner workings…
In any case, whilst I think it's good and healthy to debate the different forms of testing, their merits and tradeoffs, etc. I don't think it's appropriate when the alternative is not testing at all (e.g. "customers don't pay for tests").
I've worked at three organisations and managed to introduce automated testing to two of them. Even then, the test suites were "my responsibility", since (a) nobody else was running them and (b) I had to hand-hold people whenever I spotted a breakage (which they inevitably blamed on the test being wrong).
The heuristics I've come to follow are:
- Having automated tests is better than not having automated tests
- It's easier to improve a bad test suite than it is to get a test suite added/accepted
- There usually aren't enough tests
There are exceptions to these rules, but I don't believe them without evidence. For example, "the test suite is slow" won't convince me that there are too many tests; demonstrating systematic redundancy and fragility in the test suite might convince me (e.g. exposing privates in order to test them).
Only if people are on board with the idea of automated testing, will I bother to get more opinionated about the specifics.