57

We are in a very funny situation where I just spent two weeks fixing FE bugs and there are so many left. I asked to add integration tests but the answer was “no”, cause we can’t test the UI and all of that.

So the proposed solution was to be more careful, except I’m careful but testing whole website parts or the whole website is not feasible. What can I do?

all 26 comments
sorted by: hot top controversial new old
[-] platypus_plumba@lemmy.world 26 points 11 months ago

You need to create a list of incidents that reached customers. Create a matrix that has the incident ID, the link to the incident documentation and the type of test that would have caught the incident.

Then they'll see that their incidents would have been caught by the tests you want to. push instead of an angry customer.

[-] nitefox@sh.itjust.works 7 points 11 months ago

They know. We have had a production website being literally unusable, sucking up a lot of resources for a bug.

We have a client which is MAD cause the project is riddled with bugs, but the solution somehow is paying more attention. Except that it clearly isn't feasible to pay more attention when you have to check, recheck and check again the same thing over and over... They say it's a waste cause you can't catch UI, and you will spend the same amount of time NOT writing tests; obviously this is all crap, but they somehow think they are smarter than google or any other small or big company that do write test

[-] lysdexic@programming.dev 13 points 11 months ago* (last edited 11 months ago)

We have a client which is MAD cause the project is riddled with bugs, but the solution somehow is paying more attention. Except that it clearly isn’t feasible to pay more attention when you have to check, recheck and check again the same thing over and over…

By definition, automated testing means paying more attention, and doing it so well that the process is automated.

They say it’s a waste cause you can’t catch UI (...)

Show them a working test that's catching UI bugs. It's hard to argue against facts.

but they somehow think they are smarter than google or any other small or big company that do write test

Don't sell a solution because others are doing it. Sell a solution because it's a solution to the problem they are experiencing, and it's in their best interests to solve it. Appeals to authority don't work on everyone.

[-] Cralder@feddit.nu 6 points 11 months ago

Show them a working test that's catching UI bugs. It's hard to argue against facts.

Ooooh you wouldn't believe how easy it is for some people to argue against facts.

[-] onlinepersona@programming.dev 8 points 11 months ago

Who's saying this? Other programmers or management?

Programmers might listen to reason, but might be very set in their ways. Some that don't want it might even sabotage it and write crap tests that don't do shit like test that true == true or skip all of them. Know your crowd. If it's a crowd that like copying the latest and greatest, quote something google or facebook did or said. If they're old-school, find some old-ass programmer that loves tests.

Management listen to money unless they're incompetent. Calculate the time it took to resolve certain bugs, estimate the hourly-rate of people, compare that to how much time it takes to write tests, but make it clear that not all bugs can be caught. Maybe even find an article or blog from some manager/CTO/technical lead at another company talking about how bug count dropped or something.

If it's a free for all, add tests yourself.

If they're overbearing, bro, look for another job. A bad culture fit is a bad culture fit and there's no need to fight that. It'll be a learning experience too: not everybody can be convinced and not every company is for you.

[-] glitches_brew@lemmy.world 6 points 11 months ago

Maybe a response to their 'solution' would be to ask them if they were under the impression you weren't being careful/paying attention before the bugs occurred?

[-] friend_of_satan@lemmy.world 24 points 11 months ago* (last edited 11 months ago)

Show them the Beyonce Rule part of the Google SWE book.

We are often asked, when coaching new hires, which behaviors or properties actually need to be tested? The straightforward answer is: test everything that you don’t want to break. In other words, if you want to be confident that a system exhibits a particular behavior, the only way to be sure it will is to write an automated test for it. This includes all of the usual suspects like testing performance, behavioral correctness, accessibility, and security. It also includes less obvious properties like testing how a system handles failure.

We have a name for this general philosophy: we call it the Beyoncé Rule. Succinctly, it can be stated as follows: “If you liked it, then you shoulda put a test on it.” The Beyoncé Rule is often invoked by infrastructure teams that are responsible for making changes across the entire codebase. If unrelated infrastructure changes pass all of your tests but still break your team’s product, you are on the hook for fixing it and adding the additional tests.

[-] Anders429@programming.dev 22 points 11 months ago

What does "FE" stand for in this context? Sorry if it's obvious, I just don't see anywhere that it's actually written out.

[-] nitefox@sh.itjust.works 12 points 11 months ago
[-] iawia@feddit.nl 16 points 11 months ago

It's very hard to start writing tests for a codebase that was not tested while it was being written.

"Be more careful" is obviously just wishful thinking, but the pain apparently hasn't become bad enough for the need to better quality to have become apparent to everyone.

When people say "we can't test the UI", there's often a reason that they are reluctant. One reason can be that they think you want to test through the UI, and write slow and cumbersome end-to-end tests. Those tend to become unmaintainable at record speeds, and if you've experienced the amount of work and aggravation that can cause, you tend to become reluctant. When you ask for 'integration tests', this might be the thing people are hearing.

That being said, there's plenty of ways to test UI code locally, at the unit and component level. Depending on your tech stack, of course. Those types of tests you can just start creating without a big investment. In a codebase that's not tested, that can be difficult, but try and make the changes you need to make to isolate logic, so it can be tested as a unit test. It'll give you better code, and teach you a lot about structuring code so that you separate responsibilties.

[-] souperk@reddthat.com 11 points 11 months ago

Just do it, whenever you fix a bug, add a test case for it, the cost is not going to be noticeable. You may choose to not upload the test suite right away, but wait until someone notices and asks you about it.

[-] flumph@programming.dev 8 points 11 months ago

Just add them. You're a developer and automated testing is one of our tools. A woodworker wouldn't ask permission to sand.

[-] nitefox@sh.itjust.works 3 points 11 months ago

Then I will be scolded for wasting time adding tests

[-] glitches_brew@lemmy.world 4 points 11 months ago* (last edited 11 months ago)

Sounds like you need to answer back with numbers.

Calculate how much time is needed for writing tests.

Then calculate how much time was spent writing ineffective code, then add the amount of time it took to rewrite that same code.

I guarantee the latter amount will be more.

Bonus points if you can calculate the amount of money lost from an unavailable application, then add in the amount of money lost from the confidence your customers are losing in that app.

[-] CmdrKeen@lemmy.today 2 points 11 months ago

How do you calculate those numbers though?

It's not like your colleagues will be keeping track of how much time they've wasted writing ineffective code. If anything, they'll try to hide that by arbitrarily inflating sprint points etc.

I've worked in environments like that and the issue almost always isn't that people wouldn't LIKE it if there were tests, it's that they

  1. Don't want to have to learn something new in order to do the same job they're already comfortable with
  2. Are worried that if they convince management to let them invest X amount of time into doing something that will improve productivity, they'll be expected to be more productive in the future

And of course, all of this for no extra money. Unless you work at a place where management prioritzes developer happiness over how many sprint points the team can knock out every week (and those are rare), the sad truth is that it'll likely be about as popular as leftover food growing mold in the community fridge.

[-] 3h5Hne7t1K@lemmy.world 3 points 11 months ago

This is terrible advice. Communication is the solution.

[-] killeronthecorner@lemmy.world 0 points 11 months ago

Exactly this. They aren't for the company, they're for you to have confidence that your shipped code isn't going to blow anything up.

[-] DmMacniel@feddit.de 7 points 11 months ago* (last edited 11 months ago)

who did you ask? Write the UI Tests for your debugged components anyway. Tests are part of development, and if you cant then you write your components wrong.

[-] wccrawford@lemmy.world 5 points 11 months ago

I voted you up, but this is tough. I write tests at work when they'll help me, but nobody else maintains or creates them. Except for the tests that the boss created and insists that everyone run.

I haven't pushed terribly hard for my tests, but it's pretty obvious that I wouldn't get any traction if I did, and I'm picking my battles.

So while I agree with "write your tests anyhow", it's a lot harder than it sounds, and a lot less successful than a proper testing strategy that's embraced by the team.

[-] nitefox@sh.itjust.works 3 points 11 months ago

It's pointless if they get mad at me for "wasting time" writing tests and nobody maintains or write them.

[-] Blamemeta@lemm.ee 5 points 11 months ago

Don't. You really can't for most of it. At best, you can test whatever utility functions you have. The FE can and will break more in design than anything else, and that will never get caught by tests.

That said, try a wholistic approach. Playwright requires you to run the back end too, so you get a proper test suite going, instead of jest or whatever.

[-] nitefox@sh.itjust.works 1 points 11 months ago

Yeah I don't think unit testing would be useful. I don't think though that integration tests etc are useless though, more so now that it is possible to test the UI states too. I didn't know playwright to be fair, I read it "automatically" generates tests? Maybe I did misunderstand

[-] timdrake@lemmy.world 2 points 11 months ago

There's a VS Code extension that records the steps you took and creates the test for you. But more often than not, you would have to make some changes too.

[-] Blamemeta@lemm.ee 2 points 11 months ago

It doesn't generate them, you still have to write them. Ignore the marketing, look at the actual docs, same as any other framework.

There's a few other frameworks, I just prefer playwright because I'm used to it.

[-] GissaMittJobb@lemmy.ml 4 points 11 months ago

So you're probably not going to be able to swing getting a project greenlit to test everything on your frontend, partly because your management seems a bit stingy, and partly because it's probably not the best approach to do this kind of thing anyway.

To the claim of that you can't test UI: only if you're not creative enough. Behavior can 100% be tested, and is worthwhile to test, while UI looks can be verified with screenshot tests.

How I would probably approach this would be:

  1. Get some very basic test execution infrastructure in place. Ideally it runs in CI, but if you have to do it in the dark, then just make sure you can run it locally
  2. Try to refactor parts of the code you touch to actually have its behavior testable - do this as a part of any ongoing work of navigating the codebase
  3. Whenever you add functionality, add a test to verify it. Write the test first if you can
  4. Whenever you encounter a bug, write a test asserting the behavior you want, then fix the bug such that the test gets green.

Following these steps should successively put the codebase into a healthier state.

Another perhaps even more valid option would be to look for a better job - working in headwind from management is not recommended, as it will deteriorate your mental health.

Good luck!

this post was submitted on 05 Dec 2023
57 points (100.0% liked)

Programming

17314 readers
45 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS