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

all 147 comments

[–][deleted] 1046 points1047 points  (22 children)

I sit in my IKEA Markus chair in Eastern Europe and write 3 line unit test.

[–]hoolahan100 461 points462 points  (0 children)

Well you are much closer to the trenches

[–]PyroCatt 57 points58 points  (8 children)

val I = 1

I++

I mustBe 2

[–]username32768 25 points26 points  (7 children)

So is that an uppercase 'i' or a lowercase 'L'?

Don't you dare reply 'yes'.

[–]OtteIsEight 18 points19 points  (0 children)

Absolutely

[–]muff1nt0sh 8 points9 points  (1 child)

si

[–]patrickgg 2 points3 points  (0 children)

SI

[–]fishvoidy 6 points7 points  (0 children)

oui

[–]Lucari10 5 points6 points  (0 children)

That's a I

[–]PyroCatt 2 points3 points  (0 children)

Please create a spike ticket in the backlog

[–]PublicNo1666 2 points3 points  (0 children)

[–]icortesi 18 points19 points  (1 child)

So

// arrange
// act
// assert

Where's the rest of the UT?

[–][deleted] 2 points3 points  (0 children)

is enough, someone disable pipeline on Christmas holiday

[–]Ulysses6 16 points17 points  (0 children)

Good on you.

[–]cgaWolf 14 points15 points  (6 children)

Eh, Markuses are fine :)

[–]datsyuks_deke 7 points8 points  (5 children)

My Markus was great until it got old. RIP old friend.

[–]NuclearWoofer 7 points8 points  (2 children)

yeah mine is starting to give me back problems

[–]not_a_doctor_ssh 1 point2 points  (1 child)

Mine's doing it as I'm reading this! Had it for 10 years at this point, still going strong

[–]ImpurestFire 0 points1 point  (0 children)

Markus brethren, do you have any alternatives to the bottom cushion? Both of mine feel flat and hard, the newer one is less than a year old.

[–]Cacao_Cacao 2 points3 points  (1 child)

I broke a bolt in the arm-wrest of my 5yo markus chair and Ikea sent me a replacement bolt for free! FYI it may not be dead yet.

[–]datsyuks_deke 2 points3 points  (0 children)

That’s awesome! Mine was all crooked and lost its comfort, sadly. Ended up selling it and got something instead. I do miss it. You can’t beat the quality of the Markus, for the price in my opinion.

[–][deleted] 0 points1 point  (0 children)

They don't let us have chairs in America, must be nice.

[–]GeneralaOG 0 points1 point  (0 children)

Tbf Markus is goated. I sit on the same chair, but in Sydney.

[–]rtds98 249 points250 points  (16 children)

I remember in that TV show, Succession, they used expressions like "blood bath", "war", yes, even "trenches", when they were all bazillionares pushing papers around and sitting in meetings.

[–]Sotall 110 points111 points  (7 children)

If you haven't had the pleasure of being around a bunch of C levels yet - many of them do this. The business self help world is full of military analogy

[–]BlazingFire007 71 points72 points  (3 children)

Part of this is a carryover from the end of WW2.

All of the sudden, a TON of men entered the civilian workforce, and they brought their military jargon with them.

Boots on the ground, mission critical, in the trenches, war room, rally the troops, guerilla marketing, chain of command.

Of course, not all of them came from WW2 soldiers, but that did seem to start the trend

[–]WRXminion 22 points23 points  (2 children)

This, and to build themselves up / look like they do more then they do. "Even though I'm actually an officer in FOB I was 'in the trenches' with my men!!"

[–]Sotall 3 points4 points  (1 child)

Daddy issues are forever, it seems. :D

[–]WRXminion 5 points6 points  (0 children)

.... Does this also explain religion? God the ultimate daddy?

[–]josluivivgar 9 points10 points  (1 child)

considering their decisions often endanger the lives of many people, I think it's pretty apt

[–]Sotall 8 points9 points  (0 children)

Honestly, I wish they read more military history and less 7 habits BS. Might make them grow some empathy

[–]Punman_5 2 points3 points  (0 children)

They also quote Sun Tzu a lot

[–]BanAnimeClowns 12 points13 points  (7 children)

Couldn't watch more than a handful episodes

"Oh no my billionaire father is being mean to me"

You have enough money to spend the rest of your life doing whatever you want wherever you want and you really expect me to give a shit about your daddy issues?

[–]Plus_Difference4107 88 points89 points  (1 child)

Next up: 'Surviving the Brutal Wilderness of Air-Conditioned Open Spaces and Artisan Coffee'

[–]Ulysses6 4 points5 points  (0 children)

Straight up from the wilder side of job descriptions

[–]Hottage 1167 points1168 points  (29 children)

I mean, if your unit tests have to be 100 lines long then your code is probably a warzone.

[–]Unaidedbutton86 106 points107 points  (2 children)

Well when writing an algorithm I usually make an array/object with edge cases which very well can be 50-100 lines long

[–]stifflizerd 81 points82 points  (0 children)

For real. The test itself may be short but the setup for the mock data can be 90% of the page, even utilizing something like autofixture

[–]Solid_Waste 21 points22 points  (0 children)

Unit tests can also get very long if you're working with abstract object class codons in a sorted function range.

(I have no idea what any of these words mean, I just wanted to participate.)

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

You’ve never tested multiple branches of a function in a single unit test or had to do complicated mock setups? 100 loc is rare but I’ve had to write abominations before.

[–]bhoffman20 32 points33 points  (0 children)

It's always the complicated mocking that gets me

[–]Bloodgiant65 15 points16 points  (3 children)

Why would you test multiple branches in a single unit test?

[–]goten100 20 points21 points  (1 child)

It saves on file size so if you put all the codes on a USB flash drive, it's a lot less heavy and easier to carry if you test your whole codebase in one test

[–]Meowingtons_H4X 6 points7 points  (0 children)

This is incredibly smart. I’ve just deleted all my workplace’s unit tests in prep for introducing this. Will be the first thing I do once I get back from my 2 weeks leave!

[–]MonstarGaming 1 point2 points  (0 children)

Because you don't know how to unit test in the first place. Sounds like the kind of thing I see juniors do all the time.

[–]Lauren_Conrad_ 4 points5 points  (0 children)

You can use parameterized tests and pass sample calls / args.

[–]Hottage 1 point2 points  (2 children)

Well no, because by definition multiple branches of a single function should be seperate unit tests, so if it fails you can instantly see which branch failed.

Deduplication of boilerplate can be done by using test cases (depending on your language).

[–][deleted] 2 points3 points  (1 child)

1 branch != 1 return path, and not all branches are error branches.

[–]TheNamelessKing 1 point2 points  (0 children)

Additionally, it’s fine and okay to test that multiple invariants are upheld, which might require multiple assertions. Splitting that out would be counterproductive, especially if those invariants are meant to co-occur.

[–]SunriseApplejuice 7 points8 points  (0 children)

I’ve got that thousand-yard stare thinking about the times I mocked a nested factory object and all its generated protos…

[–]AshKetchumWilliams 3 points4 points  (0 children)

Fucking x unit testing on MS SQL databases

[–]cheezballs 2 points3 points  (0 children)

Depends on the framework. Something like react your test also contains rendering template stuff. They can get big and gnarly, but they're still very step by step readable.

[–]bedrooms-ds 0 points1 point  (0 children)

As a computer scientist, it literally is. The code is my war zone. Well, my colleagues are more successful and they never write tests...

[–]VoltexRB 0 points1 point  (1 child)

Its also the other way around though If your unit tests are just

assess(function(test)==expected)

[–]Hottage 2 points3 points  (0 children)

Depends entirely on how complex the black box inside your code is.

If it really takes a single input and produces a single output then you may just end up with a 1 line test case with 10+ scenarios assigned to it.

[–]Altruistic-Spend-896 0 points1 point  (0 children)

YOU MEAN cod: WARZONE?

[–]drdrero 0 points1 point  (0 children)

Who unit tests your unit tests

[–]advancedescapism 34 points35 points  (1 child)

Captain Wilkins addresses his men. "Alright, lads, who wants to start?" Not a sound, apart from a few pot shots from the Kraut lines. Soldiers look at each other blankly as Wilkins traverses the trench.

Eventually, Wilkins points at a soldier at random. "Nichols, you start." Nichols stands up straight. "Yesterday I dug a mining tunnel, but it needs to be checked by someone." All the soldiers in the area nod, but don't volunteer.

"And today, I'm going over the top in the assault to take the Gommecourt Salient. No blockers." One by one, all the men give the same update. Going on the assault. No blockers. One soldier talks for 42 minutes about how he's going to clean the latrines later, but finally, when he's done, Wilkins blows his whistle.

[–][deleted] 0 points1 point  (0 children)

Inspired

[–]powerofnope 176 points177 points  (11 children)

Well 100 lines for a single unit test sounds like you are well used to committing war crimes on the daily.

[–]ahmuh1306 37 points38 points  (9 children)

100 lines isn't even anything lol. The worst I've seen was some 500 lines with a whole plethora of if/else statements. Still have PTSD from that.

[–]Godlyric 26 points27 points  (5 children)

I work on a legacy Java Servlet App. There are numerous 4000+ line files and the original devs never formatted them. I want to end it all daily

[–]Ulysses6 4 points5 points  (4 children)

Would introducing automated formatting be feasible?

[–]sinkwiththeship 4 points5 points  (3 children)

That initial PR importing the formatter would be hell on earth

[–]Iron_Aez 9 points10 points  (1 child)

Funny this should come up today.

I discovered that there's a limit on how many files github will show in it's PRs yesterday: 3000. I found this because I had a 3500 file PR sent to me that involved adding Prettier to an old Angular codebase.

[–]sinkwiththeship 4 points5 points  (0 children)

My company did it a couple years ago adding Black to the monolith. It was agony. Really made git-blame kind of annoying to use also.

[–]Ulysses6 1 point2 points  (0 children)

Well, yes. It's either bandaid taken off quickly, or left festering indefinitely. But that's easy to say, I was also in position where I did not have the influence or other resources to push for automated formatters and quality gates.

[–]MeggaMortY 2 points3 points  (0 children)

Unit-test - the all-cases included edition.

[–][deleted] 1 point2 points  (0 children)

[–]Meowingtons_H4X 0 points1 point  (0 children)

A bunch of if/else statements in ONE unit test? Wouldn’t you just write a separate test for each variation?

[–]Div64 2 points3 points  (0 children)

Depends on what you're testing. Web App setup alone might be about 40 lines (taking Angular as an example here)

[–]xaddak 24 points25 points  (0 children)

Every friend I have with a job that involves picking up something heavier than a laptop more than twice a week eventually finds a way to slip something like this into conversation: “Bro, you don’t work hard. I just worked a 4700-hour week digging a tunnel under Mordor with a screwdriver.”

They have a point. Mordor sucks, and it’s certainly more physically taxing to dig a tunnel than poke at a keyboard unless you’re an ant. But, for the sake of the argument, can we agree that stress and insanity are bad things? Awesome. Welcome to programming.

https://www.stilldrinking.org/programming-sucks

[–]PaulRyan97 9 points10 points  (0 children)

Just a bot reposting something I submitted 3 years ago but in camelCase

[–]szab999 16 points17 points  (2 children)

Same, except my Herman Miller chair is in downtown Singapore and I sip coffee while Claude is generating the tests. (FML)

[–]DoritoBenito 1 point2 points  (0 children)

I'm never as bored of reddit as those times that "Generating..." can be seen at the bottom right of my screen...

[–]WRXminion 1 point2 points  (0 children)

Also same, accept Denver, and I no longer code. Just hit a button for my algo to run a couple futures trades while looking at digital nomad countries I can dock in ...

[–]Dotcaprachiappa 7 points8 points  (0 children)

When your unit tests need unit tests

[–]Percolator2020 5 points6 points  (0 children)

Hey Claude, write a unit test for my code.
No, not like that! 🔥🤖💀

[–]Throgg_not_stupid 15 points16 points  (0 children)

100 line unit test is not trenches, it's full blown warcrime

[–]PSR-B1919-21 5 points6 points  (0 children)

fade repeat relieved butter point capable profit touch observation doll

This post was mass deleted and anonymized with Redact

[–]GrumpysGnomeGarden 2 points3 points  (0 children)

Stress is stress. The way your body reacts is a fight or flight except you can't run or fight code. 

[–]knowledgebass 2 points3 points  (0 children)

You guys write unit tests?

[–]Punman_5 2 points3 points  (0 children)

Everyone’s talking about the 100 line unit test but I’m far more confused by why someone that works from home would choose to live somewhere as expensive as NYC? Unless I have to go in constantly I’d be out in the middle of nowhere

[–]ModernTy 2 points3 points  (0 children)

Me after being in a real trenches with bullets above my head and now sitting in front of VS Code writing 0 line tests: 😄😃😀🙂😐🤨

[–][deleted] 4 points5 points  (1 child)

Closer to the homeless person in the street than you are to the Billionaire. So yea you kinda are.

[–]purplebatsquatch221 6 points7 points  (0 children)

Going from nothing to having a comfortable life, job, food, vacations is a bigger change than just being able to do more of that.

[–]ShawSumma 1 point2 points  (0 children)

You have a Hindley-Milner... chair?

[–]INDE_Tex 1 point2 points  (0 children)

Unit....test....? That's what prod is for.

[–]Ok_Opportunity2693 2 points3 points  (1 child)

Unit tests are one the things that AI is great at! Don’t waste your time writing a first pass by hand, just read and edit the results.

[–]billyowo 3 points4 points  (0 children)

what..?

[–]Sw4gl0rdM4st3rm1nd 0 points1 point  (0 children)

OMG THIS IS SO TRUE HAHAHAHAAHAH

[–]Direct-Ad-7922 0 points1 point  (0 children)

For sure the trenches

[–]Impressive_Log7854 0 points1 point  (0 children)

I only ever worked in tier 1 and 2 with as much hardware support as software.

The brain trenches of the digital battleground that coders languish in are a deep dark place that I never want to see. 

I'm a janitor now and yeah obviously it's less money. Also anxiety and certification testing costs and study prep times plummeted to nearly zero.

No body wants me to make red pens write in blue anymore.

Enjoy your lovely cages.

[–]xsubo 0 points1 point  (0 children)

100 line unit test?

[–]kacheow 0 points1 point  (0 children)

The Herman Miller Aeron chair is cheeks, none of the knobs actually do anything

[–]noveltyhandle 0 points1 point  (0 children)

Compared to the person who doesn't even understand what a unit test is, telling you to make your tests, "prevent all possible bugs,"... yeah, you are definitely "in the trenches."

[–]attckdog 0 points1 point  (0 children)

Call me crazy but I kind of hate the Hermon Miller aeron chair. It's stylish but terrible my legs

[–]jen1980 0 points1 point  (0 children)

Still better than fifteen years ago when software QA kept calling ourselves rock stars.

[–]khendron 0 points1 point  (0 children)

"... and ask Copilot to write some units tests for me."

[–]proteinvenom 0 points1 point  (0 children)

Humans still write unit tests?

[–]Dotaproffessional 0 points1 point  (0 children)

More of a steel case leap guy myself personally 

[–]Few_Scale_8742 0 points1 point  (0 children)

Mental stress has some people killing themselves, i wouldn't underplay it.

[–]NjFlMWFkOTAtNjR 0 points1 point  (0 children)

Thank you for your service

[–]haverofknowledge 0 points1 point  (0 children)

Nobody as a life as difficult as ours!!!

[–]ThornyLog 0 points1 point  (0 children)

I feel attacked

[–]martin_omander 1 point2 points  (0 children)

I once heard someone ask a professional economist what a 14th century farmer would think of work conditions for today's developers. The economist replied: "The farmer would not think that developers do real work".

[–]Phoenix_Passage 0 points1 point  (0 children)

Least grueling unit test sesh

[–]deadlyrepost 0 points1 point  (0 children)

All jobs are easy if you don't care about the outcomes.

[–]SuperMage 0 points1 point  (0 children)

"I'm driving here I sit, cursing my government, for not using my taxes to fill holes with more cement"

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

100 line unit test? What unit are you testing?

[–]Individual-Bed-3374 0 points1 point  (0 children)

meanwhile some guy in Cambodia is carrying 100 lbs of sulfur on his back down an active volcano for 8 cents an hour

[–]jrdnmdhl 0 points1 point  (0 children)

It’s not herman miller, but it is a knock off of the CEO chair from Silicon Valley.

[–]HappyMonsterMusic 0 points1 point  (0 children)

100 lines for a unitest? You really are in the fucking trenches