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?

  • platypus_plumba@lemmy.world
    link
    fedilink
    arrow-up
    26
    ·
    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.

    • im sorry i broke the code@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      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
        link
        fedilink
        English
        arrow-up
        13
        ·
        edit-2
        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
          link
          fedilink
          arrow-up
          6
          ·
          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.

      • glitches_brew@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        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
    link
    fedilink
    English
    arrow-up
    25
    arrow-down
    1
    ·
    edit-2
    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
    link
    fedilink
    arrow-up
    23
    arrow-down
    1
    ·
    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.

  • iawia@feddit.nl
    link
    fedilink
    arrow-up
    15
    ·
    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
    link
    fedilink
    arrow-up
    11
    ·
    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.

  • FlumPHP@programming.dev
    link
    fedilink
    arrow-up
    10
    arrow-down
    3
    ·
    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.

      • glitches_brew@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        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
          link
          fedilink
          arrow-up
          2
          ·
          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.

    • killeronthecorner@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      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.

  • macniel@feddit.de
    link
    fedilink
    arrow-up
    9
    arrow-down
    2
    ·
    edit-2
    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.

    • William@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      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.

  • Throwaway@lemm.ee
    link
    fedilink
    arrow-up
    9
    arrow-down
    4
    ·
    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.

    • im sorry i broke the code@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      1
      ·
      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

      • Robin @lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        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.

      • Throwaway@lemm.ee
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        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
    link
    fedilink
    arrow-up
    4
    ·
    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!