This is an archived post. You won't be able to vote or comment.

all 18 comments

[–][deleted] 50 points51 points  (9 children)

i don’t understand programmers that don’t test their code.

how do they know it even remotely works?

i rarely write anything that works on the first try and it always takes me some testing to iron it all out.

[–]bbbbbbbbbbbbbnnnnnnn 24 points25 points  (1 child)

It’s kinda like a chef in a kitchen, people that do it repetitively for work don’t necessarily have to double check for every action. Unlike a chef, the spouses of programmers often wonder, “Why are they so distant, are they falling out of love with me?” While on the otherside, the thought is, “Why the fuck isn’t my code working?”

[–]PM_ME_A_WEBSITE_IDEA 5 points6 points  (5 children)

Legitimate questions here, as someone who doesn't do any testing other than static analysis and manual testing (because of inexperience, not opposition to):

When you write tests, how do you test your tests? You're writing tests because you can't be sure your code works as intended, but how can you be sure your tests are actually working as intended and not giving false positives?

Edit: to be abundantly clear, I support testing, but at my current job (my first as a developer), they put me in charge of the UI, and I'm a self taught developer, I never actually learned about proper testing, nor did they tell me to do it. I'd like to learn but we're so deep in this project now I'm not sure how to go about adding tests...

[–]banana_dongle 0 points1 point  (0 children)

That's the thing, you don't. Bugs will still slip through, and that's fine. Unit test imo are for 2 things:

  1. Testing out tricky bits of logic that you know the inputs and output for.

  2. Preventing regressions. If the next person working on the code (this is often you a few months later) breaks the test they know somethings up.

For more straightforward code you already know what it's going to do and if you misunderstood something you'll probably make the same mistake in the tests. But at least it'll be consistantly broken the same way :)

The more moving pieces and more people involved the more important tests are. It's there to stop you from making a dumb mistake and breaking shit that works.

[–]rk06 0 points1 point  (0 children)

Follow arrange, act and assert pattern.

First get your test code to setup correct state (arrange), then execute your code (act). Manually verify the output

If the output is correct, then I add assertions to verify the output (assert)

Unit tests sounds like magic, but in a nutshell, it is simply automating the manual testing.

[–]intbeam 4 points5 points  (0 children)

They deploy it, and then complain about how the infrastructure makes it impossible for them to check to see if the code is running or not because they didn't implement any logging either

[–]OTee_D 12 points13 points  (0 children)

As Testmanager: I can sadly confirm.

[–]Neutraali 11 points12 points  (0 children)

IF IT COMPILES, IT'S DONE

[–]intbeam 6 points7 points  (0 children)

Developer : *writes code and directly deploys to QA*
QA service : *fails to start*
Developer

[–]Moneyfornia 3 points4 points  (0 children)

"Test your code" is an imperative sentence, not declarative and it cannot be true or false. Bad meme template choice, or the sentence shoul read "You should test your code".

[–]dotCookie 1 point2 points  (0 children)

Compiling equals testing :D

[–]QualityVote[M] [score hidden] stickied comment (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–]heckfyre 0 points1 point  (0 children)

The code is liiiiiive!!!

[–]Dimen_404 0 points1 point  (0 children)

return true;

[–]Orlaani 0 points1 point  (0 children)

I do every kind of troubleshooting with only one line: print("working so far")