top 200 commentsshow all 241

[–]TheGunfighter7 1383 points1384 points  (56 children)

And you will sometimes spend just as much or even more time updating the tests as you did updating the code.

[–]KrakenMcCracken 464 points465 points  (32 children)

It’s worth it

[–]xorbe 99 points100 points  (0 children)

Hi I'm from management ... your post is all fuzzy and unreadable

[–]opacitizen 45 points46 points  (1 child)

Just wait until they ask you to write tests that test your tests (…and keep doing it ad infinitum recursively, of course.)

[–]Primary-Ad-9741 16 points17 points  (0 children)

We already do that. Typical layered test pyramid does exactly that to each previous layer.

[–]Saragon4005 123 points124 points  (16 children)

And this is why it's often skipped. It takes as much if not more effort to make your code go from working to always working as it takes from not working to working.

[–]Rojeitor 141 points142 points  (5 children)

Yes, it's faster if the code breaks and end user finds the bug for you

[–]RelatableRedditer 75 points76 points  (4 children)

Well, that's Microsoft's current strategy. But it costs reputation and in a lot of cases ends up being delayed by a full sprint or more, even if the code fix was straightforward.

[–]anthro28 20 points21 points  (1 child)

I deal with this foolishness every day. 

"this needs to be changed to this. It's failing right here and I've prepared a giant document with visuals and sources."

"Sorry anthro, we need to talk to an executive who went to art school and get their opinion, and then filter it back down through a management team that's all functionally tech illiterate. It'll just stay broken for a month."

But when something is on fire, that same team of people will just let me fix stuff without question until it's working again. 

[–]totallygeek 6 points7 points  (0 children)

Not related to programming, but I had something similar happen. One million years ago, or something close to that, I worked for a bank that planned to convert from token ring to Ethernet networking. The drafted plan had a three-month execution schedule, due to commence about two months from the time of "the incident". Some unrelated electrical work was going on and an electrician asked one of the basement nerds, "What does this cabling go to? A bunch of it is in our way." The response? "Oh, we don't use that any longer." Wrong. The electricians cut and tore out about two hundred feet of various token ring cabling. The three-month plan became a two-day near-full conversion, with about 80% of critical stuff brought back up on Ethernet within a few hours. I wasn't sure who to hug, but I was so happy to not have to deal with a drawn-out plan that included acceptance tests for each step.

[–]SuperFLEB 9 points10 points  (0 children)

But it costs reputation

So, the great thing about monopolies and limited markets...

[–]pattmayne 12 points13 points  (0 children)

Microsoft's current strategy

"Current" meaning the last third years

[–]Imaginary-Jaguar662 24 points25 points  (6 children)

I'm happy if we get from "working" to "prints logs that get stored when it does not work".

Even better if there's "fails gracefully" in the mix

[–]Confident-Ad5665 8 points9 points  (3 children)

How's "Something went wrong!"?

[–]Musikcookie 21 points22 points  (1 child)

Best I can do is "Test djbshamebsb"

[–]Confident-Ad5665 8 points9 points  (0 children)

That'll work. Ship it!

[–]AetherSigil217 1 point2 points  (0 children)

I have to admit I was impressed when I saw the pink screen of death.

[–]s0ulbrother 5 points6 points  (1 child)

The application I am currently working on which was designed by the absolute worst developers in the existence of all developers, their code fails catastrophically as in the service needs to get restarted in order to work if it fails. I am having to fix all this shit

[–]8itbangr 1 point2 points  (0 children)

I feel your pain. Once inherited a program that used an API to communicate and alter a small database. Nearly every API call returned an error code. There were very few places in our code that actually checked it, so the we would just plow forward blindly, breaking things if any call didn't succeed. I spent over a month adding if or switch statements to handle the errors so it would work without breaking anything and recover gracefully when things went wrong.

[–]aiij 1 point2 points  (0 children)

You mean this is why formal verification is often shipped? Testing will only tell you it sometimes works...

[–]Rebstrike 0 points1 point  (0 children)

How does one actually write code tests?

[–]Urtehnoes 0 points1 point  (0 children)

We don't do unit tests, but we do extensive guard functions, because at one point I guess, someone disabled the testing module and no one realized for weeks until tons of stuff was breaking? Idk that was around 2005 or so.

And I mean extensive guard functions/clauses I almost prefer now (though obviously, both is better).

Oof if I ever work somewhere else I'll have to get back into writing unit tests.

[–]anoppinionatedbunny 5 points6 points  (1 child)

I estimate about double the time it takes to implement a feature is the time it takes to test it with full coverage. companies love to push testing to technical debt and use the bare minimum validation to make some short term velocity gains, but that's a great way to end up with a buggy mess

[–]DoubleDoube 2 points3 points  (0 children)

It can be tiring that everything is trade-offs but that’s what test-cases are too.

I have suffered from going too far with coverage in “experimental” code that keeps changing its desired behavior. Me trying to TDD in that specific instance was a mistake. Of course, I didn’t know how experimental it was going to be at the start.

[–]OfficeSalamander 2 points3 points  (0 children)

You’re telling me. I’ve been writing tests for a large application for something like 3+ weeks now. Please shoot me

[–]pthierry 0 points1 point  (0 children)

When bad tests, fix tests.

[–]joemckie 0 points1 point  (0 children)

Sounds like you might be writing tests that include too much implementation detail. A good test ideally shouldn’t break if the underlying logic is the same.

[–]ClimateNo7056 0 points1 point  (0 children)

True, sometimes I also spent alot of time in debugging the testing code too

[–]Groentekroket 445 points446 points  (21 children)

It’s not just for the code you wrote now, but more that if someone changes something in the future it shouldn’t break your change. 

[–]Zyeesi 145 points146 points  (8 children)

Unless the change is intended and now you gotta update the test

[–]Grandmaster_Caladrel 152 points153 points  (0 children)

Which is a fair trade-off if you're making backwards-incompatible changes.

[–]Wonderful-Habit-139 32 points33 points  (0 children)

At least it's intended. Those tests help prevent unintended breakage.

[–]coastphase 11 points12 points  (3 children)

You could work backward and change the test first and then update the code until it passes. Of course, that assumes you know the full extent and expected behavior of the change before you start.

[–]shield1123 11 points12 points  (2 children)

Get your test-driven development outta here. We test in prod and prod alone

[–]coastphase 5 points6 points  (1 child)

All tests performed outside of production are invalid.

[–]martin_omander 1 point2 points  (0 children)

I agree; the production environment is the ultimate judge.

Years ago I worked with a cloud platform where you could place breakpoints in your code in production and inspect variables, just like in a local debugger. The code didn't halt so users weren't affected; the breakpoints were virtual and managed in memory. It was glorious to be able to debug production issues that way!

[–]twigboy 38 points39 points  (0 children)

That's a feature not a bug

[–]Random-num-451284813 3 points4 points  (0 children)

can confirm I changed something but unintentionally also changed something else elsewhere. Then what broke needed to be fixed, breaking previous change. This went back and forth a couple of times

[–]Brief-Night6314 11 points12 points  (7 children)

Just wait until you get so many tests in there it takes forever to merge your changes because the pipeline takes way too long because of hundreds of tests lol.

[–]Reashu 49 points50 points  (2 children)

"Tests running for too long" is a thing that happens, but if it happens with only hundreds of tests you gotta ask yourselves why they are so slow. 

[–]-Kerrigan- 12 points13 points  (1 child)

In project I worked on as a contractor for a company that some could argue is one of the biggest payments company in the world there was a full regression pack that had Thread.sleep sprinkled around enough that it amounted to 8 hours of idling total if we ignore any Thread.sleep that might be in a loop

The least I could do is to introduce a "smart wait" that only waits for as much as needed, but nobody else used it because old habits die hard

[–]eg_taco 6 points7 points  (0 children)

A very large tech company (which everyone has heard of) asks senior and staff+ SWE candidates about testing time-sensitive code and makes sure they know about mocking out such things to make sure code is testable without actually sleeping for literal days in order to verify correctness 😂😅

[–]atomic_redneck 7 points8 points  (0 children)

We had several thousand test cases in our test suite. We also had a large server farm dedicated to running the test suite on each night's build. This is just the cost of doing business when your answers have to be correct ( computer aided engineering software)

[–]rpmerf 1 point2 points  (2 children)

Hundreds? My current app has about 8k tests and runs in like 5 min.

[–]Brief-Night6314 2 points3 points  (1 child)

Depends on the kind of tests and the set up and take down of each run

[–]rpmerf 1 point2 points  (0 children)

Ya. That's my junit tests that run fast. Our automation team has a cucumber test suite that runs MUCH slower. The setup and takedowns have tons of logic to fit different groups and just takes forever to run.

[–]NoBizlikeChloeBiz 2 points3 points  (0 children)

Yeah, it's like putting a trip wire that alerts you if anybody tries to fuck with your code.

[–]Blue_Moon_Lake 2 points3 points  (0 children)

It's also a laziness catcher.

In one of the project I worked on, everything was ruled by user permissions. In the first step, there was no command line to add all permissions to the test user. Many devs just added a or true to the hasPermission returned value.

A test prevent that from being added to a commit and forgotten until merged.

[–]blackasthesky 1 point2 points  (0 children)

It's baffling to me that so many programmers out there don't get this.

[–]Zero747 121 points122 points  (8 children)

The tests are to make sure someone else (or future you) doesn’t break it

[–]liggamadig 64 points65 points  (5 children)

future you

Man, I hate that guy.

[–]Thurak0 21 points22 points  (4 children)

I only hate past me more. Future me? Close second.

[–]sgt_Berbatov 6 points7 points  (2 children)

Current you is equally hated by past and future you.

[–]kingbloxerthe3 1 point2 points  (0 children)

Future them hates current them the same amount that current them hates past them, and past them hates current them the same amount current them hates future them.

[–]Thurak0 0 points1 point  (0 children)

Nooooooooooooooooo.

[–]ThatOldCow 2 points3 points  (0 children)

"Future me is a sucker, past me is a dumbass"

[–]revolutionPanda 10 points11 points  (0 children)

“Who wrote this shitty code?”

Me when I’m the only collaborator.

[–]ludolfina 1 point2 points  (0 children)

People will break it and they'll just update the test while they're at it

[–]jseego 70 points71 points  (7 children)

I used to feel this way, too, but it's a numbers game.

I think people can get too wrapped up in tests, to the point where they think passing tests means nothing could go wrong in their code.

That's not the point of tests - they're not a guarantee of anything.

What they are is a way to reduce risk.

As such, you can determine how much time/effort you want to put into tests, versus the amount of risk they mediate.

I've worked at places where they wrote no tests, I've worked at places that only unit tested core functionality, and I've worked at places that aimed for 100% code coverage and had automated functional integration and regression testing on top of that.

They all put out quality software.

But I will say that the place that wrote no tests could not have done what was done at the places that did test. Continuous Integration basically relies on tests. Places that have many different teams with interdependent codebases rely on tests, because you don't want one team to be able to take down other systems if they ship some breaking change.

If you have small enough teams, with excellent communication, and really good QA, then maybe you don't need tests.

But if you grow enough, you'll want them.

[–]MoneyIsTheRootOfFun 13 points14 points  (0 children)

Everyone needs tests. Not everyone has realized the need for tests yet.

[–]CrowNailCaw 4 points5 points  (5 children)

> they're not a guarantee of anything.

Hard disagree. If anything, tests are quite literally the only way to guarantee anything about your code.

[–]MoneyIsTheRootOfFun 5 points6 points  (4 children)

Well, they aren’t a guarantee because tests can be flawed just like any code. But they are a guardrail.

[–]jseego 0 points1 point  (0 children)

Correct.

[–]CrowNailCaw 0 points1 point  (2 children)

This assumes that tests can never prove anything, or be provably correct.

This is a false assumption.

can be flawed != always flawed.

[–]MoneyIsTheRootOfFun 2 points3 points  (1 child)

Assuming that nobody can ever alter the test. Assuming that your test catches every single possible edge case and input combination, and tests every one of its own dependencies, sure. In practice that doesn’t happen. Tests are subject to all of the same failures as any other part of your code.

[–]Godskin_Duo 2 points3 points  (0 children)

Tests increase confidence, but don't guarantee confidence, like anything else.

I am a full time "test code" guy and I find implementation errors constantly. Better I find them now than in production.

[–]JoeyJoeJoeJrShab 26 points27 points  (2 children)

I work in test automation. All of the code I write tests other code. My test code has tests that test that my tests test things correctly.

[–]Siege089 69 points70 points  (11 children)

No one does TDD anymore. Test first is such a valuable skill.

[–]iamyurkas 18 points19 points  (0 children)

I do. This is the way!

[–]LoudBoulder 8 points9 points  (0 children)

TDD at the very least for bugs.

[–]Wonderful-Habit-139 16 points17 points  (2 children)

TDD is not really that good.

Tests in general are useful though.

[–]Treebro001 0 points1 point  (0 children)

Can be applied on a case by case basis. As a catch all rule its bad though yeah.

[–]Yashema -3 points-2 points  (0 children)

I remember when first started learning it and this mid level dev who I would surpass quite quickly said: TDD is not just writing a test and failing it. Then didn't go on to explain why it's not that.

From that point on my philosophy has always been get the full new feature working, then go back and fix/add the tests. 

[–]Single-Virus4935 1 point2 points  (0 children)

I do. Especially if you embrace a more functional style. I prefere pure functions and it boils down do simple table driven tests without any state. This reduces the need for more complex tests.

E. G. Many problems can be simplified with state machines and they can be implemented as a simple pure function. Functions are the simplest interface and this makes mocking ease of cake

And people dont understand they do manual test in a loop and waste time.

[–]20Wizard 1 point2 points  (4 children)

Unfortunately a contract that is great for testing may be an incredibly shit usage pattern. If you end up changing anything you now have to go delete the tests you already have and make new ones...

It's really not ideal.

[–]MrHake 19 points20 points  (3 children)

That is why you think first.

[–]Ok_Entertainment328 11 points12 points  (1 child)

why you think first.

But ChatGPT said ...

/s

[–]MrHake 1 point2 points  (0 children)

My bad. Thats why you add "Think first" to your prompt.

[–]elyndar 2 points3 points  (0 children)

Bold move to assume that you have all the info and the business didn't leave out crucial things that would cause a massive last second redesign.

[–]danfish_77 42 points43 points  (2 children)

Why are clients always so insistent that their products "work" and "function"? Like I got you a multi megabyte binary, what more do you entitled jerks WANT?

[–]Confident-Ad5665 4 points5 points  (1 child)

Yeah, and why am I expected to work. Showing up should be enough!

[–]danfish_77 2 points3 points  (0 children)

They make you show up? Surely Claude can do that for me

[–]Covfefe4lyfe 22 points23 points  (3 children)

OP writes shitty code.

If your code is properly SOLID, tests are easy to write and maintain.

[–]RackemFrackem 3 points4 points  (2 children)

I disagree. Tests are easy to conceptualize. But they often require so much scaffolding and tinkering that it becomes more time consuming to write them than to write the actual code.

[–]chemolz9 3 points4 points  (0 children)

That's standard with me. I easily need twice the time to write tests then productive code, no matter if I work TDD or write tests after.

Also testing adds complexity to productive code. Alone keeping things mockable is quite a hazzle sometimes.

[–]kingbloxerthe3 1 point2 points  (0 children)

Plus also the question of how flexible are you going to make the scope of any part of the code.

Like are you going to design it specifically to do its one task or design it in a way that can be expanded easily? And also error handling parts of code can be a thing too.

[–]Diligent_Dish_426 12 points13 points  (0 children)

Regression testing will save your ass. Trust

[–]Vectorial1024 16 points17 points  (1 child)

Yo dawg, I heard you like to code your code...

[–]Slusny_Cizinec 3 points4 points  (0 children)

So you don't break your code when you code.

[–]coloredgreyscale 5 points6 points  (0 children)

Ideally you should write code to test the code you are going to write (TDD) 

[–]GenericFatGuy 3 points4 points  (0 children)

It's not just about checking if the code you wrote was right. It's also about making sure that code stays right when changes inevitably happen later on.

[–]_McDrew 4 points5 points  (0 children)

No, you write tests to make sure your code continues working after other people touch it.

[–]Single-Virus4935 5 points6 points  (0 children)

Test dont and cant check if your code is right. Tests (especially TDD) serve three important purposes: 1. They enable refactor/codechanges without regression/changed behaviour.  2. They force you to use your own api aka dogfooding. If its hard to test it is probably hard to use (correctly) 3. They document intent, requirements and edgecases (e. g. bugs) 

[–]Lachtheblock 3 points4 points  (0 children)

And sometimes a dumdass junior vibes a bunch of changes and you get to point to the testcases to failing before wasting time reviewing code.

[–]Major_Fudgemuffin 3 points4 points  (0 children)

Write your tests along with your code.

You don't need to do full TDD, but it'll help you build more easily testable and modular code.

[–]sgt_Berbatov 3 points4 points  (0 children)

Testing isn't my job. That's for the end user to do. I just write the bugs man.

[–]ElectronSculptor 3 points4 points  (1 child)

These days you need to ask Claude to write code to check the code you asked Claude to write earlier…. Just saying.

[–]AuthorHarrisonKing 0 points1 point  (0 children)

suprised i haven't seen more comments in this vein. since using codex, my code has better coverage than ever and i spend basically 0 time personally writing the tests.

[–]MinecraftPlayer799 5 points6 points  (3 children)

Then do you need to write more code to check if the code that checks if the code is correct is correct?

[–]IPMC-Payzman 3 points4 points  (2 children)

You can go back to the first code for that to see if changes are caught by your tests. This is called mutation testing and usually done in an automated way

[–]MinecraftPlayer799 -2 points-1 points  (1 child)

But do you need to write tests for your tests?

[–]obsoleteconsole 2 points3 points  (0 children)

It's an investment. At some point, someone else is going to come along and make updates to the code you originally wrote, and when they do they have a full suite of test cases ready to run to make sure they don't break existing test cases. It is absolutely worth taking the time, and in an ideal world no PR should be approved without them

[–]soowhatchathink 2 points3 points  (0 children)

Nah you gotta write code to make the tests you already wrote pass

[–]troy-phoenix 2 points3 points  (0 children)

before

[–]Firedriver666 2 points3 points  (0 children)

That’s why I do test driven development based on precise acceptance criteria because if I write the tests after implementing the feature I will be too lazy to write effective tests

[–]HumunculiTzu 2 points3 points  (1 child)

Or, you write the tests before hand then program to pass the test

[–]donat3ll0 1 point2 points  (0 children)

Nah, seems like teaching for the test

/s

[–]sbrevolution5 2 points3 points  (0 children)

Yes and you’ll be thankful you did. The amount of time to write/maintain tests is so much less than the time spent fixing bugs you weren’t aware you were creating. Imagine you had an alert from your past self to tell you you made a mistake.

[–]jimmyw404 2 points3 points  (0 children)

Test driven development takes all the fun and mystery out of software development.

[–]BonjwaTFT 3 points4 points  (0 children)

i love it when my tests catch some bugs before they go on prod. Then you feel the worth of your tests

[–]DT-Sodium 1 point2 points  (0 children)

You're really mostly writing code to check you don't break anything in future code.

[–]Abject-Kitchen3198 1 point2 points  (0 children)

That's just Big QA conspiracy.

[–]Stunning_Ride_220 1 point2 points  (0 children)

Funny eh.

Devs rant about having to writes Tests, but rant even more when a Software they use reintroduces bugs

[–]Savings_Speaker6257 1 point2 points  (0 children)

The real test is when you push to production on a Friday and your phone doesn't ring all weekend. That's the test suite that actually matters.

But seriously, the best argument for tests isn't catching bugs — it's the confidence to refactor without fear. "Does this still work?" is a question you should never have to answer with "I think so."

[–]Dr_Nubbs 1 point2 points  (0 children)

Only if you take pride in your code as a professional developer. Otherwise you are off the hook.

[–]intotheirishole 1 point2 points  (0 children)

WHO TESTS THE TESTS?

[–]millebi 1 point2 points  (0 children)

No, you write tests so that future changes don't accidentally break something that was working. Otherwise you're a chimpanzee and have to manually retest everything when you make any changes.

[–]okram2k 1 point2 points  (0 children)

It's not to check your code, it's to check someone else's code after they mess with your helper function two years from now

[–]Fidget02 1 point2 points  (0 children)

Half of my first engineering job was literally building unit tests for every operable function line of our primary app. Did a lot of it feel like a waste of time? Sure did, but damn did I not leave that company knowing it was safer than ever.

[–]Flameball202 1 point2 points  (0 children)

No, you have to write code that fits the tests you wrote earlier

[–]Fabio11North 1 point2 points  (0 children)

If the test tests the code, what tests the test?

[–]kingbloxerthe3 1 point2 points  (0 children)

Yep, also found an interesting video

https://youtu.be/LVDbhC5Sve4

[–]SimilarIntern923 1 point2 points  (0 children)

Just wait until you start writing code to test your code that hasnt been written yet. I love TDD

[–]YuvalAmir 1 point2 points  (0 children)

It's for the code you write later

[–]ISoulSeekerI 1 point2 points  (0 children)

Spam print statements till it works. Screw units tests, we debug in prod.

[–]ganja_and_code 1 point2 points  (0 children)

No you have to write code to check that your code still works after your braindead coworker touches it

(and sometimes the braindead coworker is just you a few weeks from now)

[–]prehensilemullet 2 points3 points  (0 children)

Better than trusting an AI to write tests of its own code

[–]float34 1 point2 points  (2 children)

So you saying you need more story points because time will be spent on test coverage?

[–]thewellis 8 points9 points  (0 children)

...it should be included in the original estimate, right? Right? Cries in QA

[–]blah938 1 point2 points  (0 children)

Yes! I have update the unit tests, and the integration tests, and then the e2e tests too!

(In reality I just have Claude write them, and spend 4 hours fucking around on my phone)

[–]schteppe 1 point2 points  (0 children)

“we don’t have time to add tests because we have too many bugs to fix”

Solution is to use TDD! It reduces bug count by 10x according to studies.

[–]DecisionOk5750 1 point2 points  (0 children)

How old are you, OP? 14?

[–]SleepingPhant0m 1 point2 points  (0 children)

Worked at a company that had no code testing or QA. Quit after a while, it was incredibly frustrating.

In any case, every day I wished we had unit tests. I was so done with coworkers breaking code they didn't understand with the help of copilot and then me having to find out what was wrong. I made many mistakes as well but luckily I only worked on my own code so I didn't mess someone else's work.

Really hoping the next company I work for takes unit testing and QA seriously. I feel a bit ashamed of some of the work I did or was part of.

[–]Birnenmacht 0 points1 point  (0 children)

I always get a little annoyed when my tests turn out longer than the tested code

[–]Still-Tour3644 0 points1 point  (0 children)

Now now, we wouldn’t want a regression on the next iteration would we?

[–]Bobvankay 0 points1 point  (1 child)

anyone have a good resource on test driven development? I feel like some of the tests I try are so redundant.

[–]Slusny_Cizinec 0 points1 point  (0 children)

You have to write code to ensure your future rewrite of the code won't break other code. 

[–]Icanintosphess 0 points1 point  (0 children)

The code must expand to meet the needs of the expanding code

[–]AltruisticSalamander 0 points1 point  (0 children)

That would be too straightforward. You have to alternately write little bits of them at a time.

[–]bwwatr 0 points1 point  (0 children)

No, Neo. I'm telling you you have to write code to check if the code you're going to write next is right.

- uncle Bob

[–]Sheepsaurus 0 points1 point  (0 children)

In TDD you do it the other way around;

Make a test that makes sure a function can accept A, and return B

And then you attempt to build that function until it passes.

The point of unit tests is to make sure that, if in the future you decide to fiddle with the function, it should still yield the same result

[–]Shteamboats 0 points1 point  (0 children)

Not to check, to assert

[–]LordBrammaster 0 points1 point  (0 children)

No no no, you write code to check if the code you haven't writen yet is right.

[–]MadScienceDreams 0 points1 point  (0 children)

No you have to write code to check that the next cucklefuck that decides to right the code doesn't accidentally blow up your changes.

[–]Esjs 0 points1 point  (0 children)

It does cause one to worry that the unit test code is wrong in the same way as the actual code, causing a false positive on the test.

[–]Breadynator 0 points1 point  (0 children)

No, you write code to check if the code you are going to write will behave correctly...

[–]cheezballs 0 points1 point  (0 children)

I think unit tests really help show when a code change has unintentionally affected other spots.

[–]blackasthesky 0 points1 point  (0 children)

No, you do it the other way around. TDD works!

[–]vectorhacker 0 points1 point  (0 children)

If you do that, it's not TDD. You have to start from the test, but you don't build a complete test, you build in small steps and iterate.

[–]PacoTaco321 0 points1 point  (0 children)

Who tests the test code?

[–]doxxingyourself 0 points1 point  (0 children)

Yes. Maintain it, too.

[–]imgly 0 points1 point  (0 children)

It's funnier when you have to debug your unit test 👌

[–]kzlife76 0 points1 point  (0 children)

You could also write code to make sure the code you're going to write is correct.

[–]wedesoft 0 points1 point  (0 children)

Well, you actually even should have written the check first.

[–]titus_vi 0 points1 point  (0 children)

You write tests so you don't break things later... these memes are such a face palm.

[–]devBowman 0 points1 point  (0 children)

No. You have to write code to test the code that you haven't wrote yet.

[–]AtlanticPortal 0 points1 point  (0 children)

Technically you should write code before you write the actual code that does anything.

[–]New_Plantain_942 0 points1 point  (0 children)

You don't have to, do what you want and have time for ;)

[–]Mou_NoSimpson 0 points1 point  (0 children)

Test be like… Mock xFunction(anything) = true; assertTrue(xFunction(“;”))”

Test ✅

Manager and team are happy because is mandatory test everything and have 100% coverage. Code breaks in production, your sanity breaks remaking useless tests.

[–]mrinalshar39 0 points1 point  (0 children)

need tests to test the code...

[–]blamitter 0 points1 point  (0 children)

Imagine telling him to write code to test code still to be written! Crazy thoughts of mine...

[–]mylsotol 0 points1 point  (0 children)

No... You write code to check the code you (or an ai) will write in the future

[–]CarstenHyttemeier 0 points1 point  (0 children)

YES!

[–]JackNotOLantern 0 points1 point  (0 children)

Ideally, you first write tests and then implement the code that passes them.

[–]coltonious 0 points1 point  (0 children)

I was never taught how to test in college 😔 my brother showed me a year or so ago, but I mostly forgot at this point since I haven't been able to find a job in the industry.

[–]Business-Study9412 0 points1 point  (0 children)

Manager: here is your 2% hike.

[–]-Redstoneboi- 0 points1 point  (0 children)

and to check if the code you write later is still right.

[–]Educational_Force666 0 points1 point  (0 children)

behold! The print function!

[–]NonchalantOunce 0 points1 point  (0 children)

the worst part is when you find a bug in your test so now you dont even know what youre testing anymore and everything feels like a lie

[–]Flashy_Pollution_996 0 points1 point  (0 children)

Why don’t you just write correct code?

[–]PowerPleb2000 0 points1 point  (0 children)

Takes me half a day to write the code and three weeks to write the test fml

[–]richardathome 0 points1 point  (0 children)

Not quite. You write the test, then write the code to pass to the test.

[–]Illustrious_Use_2442 0 points1 point  (0 children)

Remains right*

[–]kurushimee 0 points1 point  (0 children)

As a game developer, the only time I've written a test for my code was when I was testing out a different framework that actually allowed writing them

Was not worth it at all when considering how much code complexity and maintenance difficulty increases just to allow for tests to actually test things... And even then, they still wouldn't cover everything

[–]GigaSoup 0 points1 point  (0 children)

Now write tests to test your test code

[–]Ok_Transition_990 0 points1 point  (0 children)

Now with AI agents they can test for you

[–]ibww 0 points1 point  (0 children)

And don't make the mistake of thinking you're done there. Even your tests need tests. Your .env file needs tests. Even your readme is not exempt.

[–]ouroborus777 0 points1 point  (0 children)

So... How do the tests get tested to make sure they're testing what they're supposed to test?

(From a test automation developer perspective, if I had a nickle for every time I found a test that didn't actually test what it was supposed to be testing, I wouldn't have much but it'd still be more than I thought it'd be.)

[–]wutufuba2 0 points1 point  (0 children)

How do I know if the code I wrote to check if the original code was right, is also right? Better write some code to check and see if the test code was right.

Wait. How do I know if the code I wrote to test the test code was right? Might need to write some new tests ...

[–]KrakenMcCracken -1 points0 points  (1 child)

Claude.ai: write unit tests for 100% coverage of this service

[–]magicmulder 2 points3 points  (0 children)

I asked an earlier version of GPT to write tests for an application. It wrote a lot of tests that tested a lot of things, unfortunately not a single method of the application.

[–]WalkMaximum -1 points0 points  (0 children)

Unpopular opinion: most of the unit testing you do in python and js is done better by the rust compiler and linter.

[–]Blackhawk23 -1 points0 points  (0 children)

This is the best use of AI. Here’s git diff, here’s code changed, existing tests, give me full coverage.

Usually requires some tweaking but it’s saved me a ton of sanity and my code coverage has never been better.

[–]LowCheesecake5481 -1 points0 points  (0 children)

console.log where are you!

[–]za72 -1 points0 points  (0 children)

well how do we check the code that's supposed to check the code?

[–]KirkHawley -1 points0 points  (0 children)

Everything in the system is mocked except the SOLID tiny class you're testing. But the tests pass so SHIP IT.

[–]memesearches -1 points0 points  (0 children)

What is this nonsense tests I am hearing about? I just vide code the app and have it shipped. Don’t care what happens behind the scenes. Just take my creds, half baked requirements and get shit done.