6

I'm a strong believer in the triple-A unit-test pattern: Arrange, Act and Assert

Anyone else that uses this for their tests? Do you see any cons to using this approach to writing tests? Are you using an alternative?

Comments
  • 0
    I'll tell you once I start writing tests.
  • 0
    I don’t believe in unit tests lol
  • 0
    Yes, I use this a lot, with the equivalent terms "given, when, then". I find that extracting methods that start with these leads to very readable tests. Like givenEmptyAddressBook(), whenAddingContact() etc.

    Though you have to refrain from abstracting too much, or readability suffers again. I've had coworkers attempting to create given-when-then builders you pass lambda functions to, in order to "solve this once and for all". You can solve everything with layers of abstraction, except having too many layers of abstraction, as they say.
  • 1
    @uyouthe
    > I don’t believe in unit tests lol

    Stop writing software like the Wright brothers built airplanes: Cobbling together the whole thing, then pushing it off a cliff to see if it crashes. Would you laugh at wind tunnel testing? I hope not.
  • 0
    @VaderNT You constructed your sentence just like Wright brothers, but with rough assumptions instead of wood. How ironic

    Wouldn’t laugh at wind tunnels but would laugh at you
  • 0
    @uyouthe your reply carries about as far as the Wright's prototypes. Try fueling it with clarification - it's you who said "I don't believe in unit tests lol" which in almost all situations translates to "I'm being unprofessional".
  • 0
    @VaderNT if you think not believing in unit tests is being unprofessional, you should probably now be where you belong – under uncle bob’s table, sucking his dick. Sorry, gotta go, CTO job is a busy one.
  • 0
    @uyouthe could you provide your arguments for that opinion? I'm curious
  • 0
    @uyouthe waving around Uncle Bob's dick or yours is a lot less impressive than actual arguments. If you had any, you could've easily provided them by now. That speaks for itself.
  • 0
    @VaderNT @alexbrooklyn can I convince you two boubas? Yes. Do I care about what you two boubas think? No, not at all.

    Having trouble with code quality? Write a lot of tests. And I mean a *lot*. Test every file in isolation. Mock as many imports as possible.

    When you're done, your code will still be bad, but now your tests will make sure it's impossible to improve anything in any meaningful way.
  • 0
    @uyouthe
    I see you've expanded on this in your rant: https://devrant.com/rants/3006186/...

    Thank you. That was a good idea, since this isn't what this rant here is about. So I'll continue on your rant.
Add Comment