Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "passing all tests"
Me: Why did you just delete the failing unit tests?
Intern: I debugged it for a while and found one of the other developers broke it with his recent changes. I couldn't fix it.
Me: Did you let him know he broke it?
Me: So you just deleted it and decided to pretend the feature isn't broken?
Intern: ... No ... I mean ... well you told us yesterday we needed to have all the tests passing.
(I NEED a stress ball people)30
I delivered a small C# program long time ago.
Unit tests, integrations tests, functional tests, all passing (users even happy).
Colleague of mine approached me.
C: "I finally fixed the program"
M: "Which program?"
C: "Product X"
M: "What was wrong with it?"
C: "Nothing, but now it runs on Python"
C: "Yeah, we lost a few features, but it's Python!"
M: "Aren't you busy with other things?"
C: "That can wait"
Fuxk yeah! My code works! It's 2AM, I'm happy and there's no one around, so I wrote a poem :-P
What was once impossible,
Is now close to completion,
Thanks to my debug statements,
Which now await their deletion.31
I spent about 5 hours today coding and I was totally in the zone. I'm talking things were working properly, tests were passing, bugs were being squashed all over the place. It was completely amazing, I felt like a god ruling over my code kingdom.
After about 5 straight hours I realized that I needed food so I got up, stretched my legs and had some dinner. Well I sat back down about an hour ago and I am SO far out of the zone. Everything is breaking, I can't focus and I have no idea why. My kingdom was overrun with a plague of bugs in just the short time I paused to eat.
Moral of the story: when you get in the zone don't stop for anything even if it seems like basic human necessity. After all we aren't human when we're in the zone, we are coding gods.7
I wrote a database migration to add a column to a table and populated that column upon record creation.
But the code is so freaking convoluted that it took me four days of clawing my eyes out to manage this.
BUT IT'S FINALLY DONE.
Why so long, you ask? Just how convoluted could this possibly be? Follow my lead ~
There's an API to create a gift. (Possibly more; I have no bloody clue.)
I needed the mobile dev contractor to tell me which APIs he uses because there are lots of unused ones, and no reasoning to their naming, nor comments telling me what they do.
This API takes the supplied gift params, cherry-picks a few bits of useful data out (by passing both hashes by reference to several methods), replaces a couple of them with lookups / class instances (more pass-by-reference nonsense). After all of this, it logs the resulting (and very different) mess, and happily declares it the original supplied params. Utterly useless for basically everything, and so very wrong.
It then uses this data to call GiftSale#create, which returns an instance of GiftSale (that's actually a Gift; more on that soon).
GiftSale inherits from Gift, and redefines three of its methods.
GiftSale#create performs a lot of validations / data massaging, some by reference, some not. It uses `super` to call Gift#create which actually maps to the constructor Gift#initialize.
Gift#initialize calls Gift#pre_init (passing the data by reference again), which does nothing and returns null. But remember: GiftSale inherits from Gift, meaning GiftSale#pre_init supersedes Gift#pre_init, so that one is called instead. GiftSale#pre_init returns a Stripe charge object upon success, or a Gift (and a log entry containing '500 Internal') upon failure. But this is irrelevant because the return value is never actually used. Pass by reference, remember? I didn't.
We're now back at Gift#initialize, Rails finally creates a Gift object using the args modified [mostly] in-place by all of the above.
Another step back and we're at GiftSale#create again. This method returns either the shiny new Gift object or an error string (???), and the API logic branches on its type. For further confusion: not all of the method's returns are explicit, and those implicit return values are nested three levels deep. (In Ruby, a method will return the last executed line's return value automatically, allowing e.g. `def add(a,b); a+b; end`)
So, to summarize: GiftSale#create jumps back and forth between Gift five times before finally creating a Gift instance, and each jump further modifies the supplied params in-place.
Also. There are no rescue/catch blocks, meaning any issue with any of the above results in a 500. (A real 500, not a fake 500 like last time. A real 500, with tragic consequences.)
If you're having trouble following the above... yep! That's why it took FOUR FREAKING DAYS! I had no tests, no documentation, no already-built way of testing the API, and no idea what data to send it. especially considering it requires data from Stripe. It also requires an active session token + user data, and I likewise had no login API tests, documentation, logging, no idea how to create a user ... fucking hell, it's a mess.)
Also, and quite confusingly:
There's a class for GiftSale, but there's no table for it.
Gift and GiftSale are completely interchangeable except for their #create methods.
So, why does GiftSale exist?
I have no bloody idea.
All it seems to do is make everything far more complicated than it needs to be.
Anyway. My total commit?
IN FOUR FUCKING DAYS!
A story from back when I was about to quit my first job,
I was the only front end in my first job after I graduated, it was a small IT company which needless to say, the pay sucks, the boss sucks, the manager sucks, everything sucks.
Despite that, I learnt a lot of things, but that's a story for another occasion.
So one day during my one month notice period, the HR asked me to help her in selecting candidates for my replacement. Being the good samaritan I am (trying to leave on good terms), I helped her by creating some practical test for the applicants.
It only took me an hour or so designing the tests, and another hour to try it out myself, and making sure it fulfill certain traits I'm trying to dig out of the candidates.
The test itself is pretty simple (in my opinion at least), in a sense that if someone are applying as a "front end", these are definitely the basic skills they should be having.
These may not be the exact wording as I remember, but the tests are,
1. Construct an HTML container which contains 4 other container, and responsively scales it's width on x screen size, x screen size ... and so on
(Requires a very basic media query)
2. [a screenshot of an HTML table], recreate the table in HTML, _as similar as you can to the screenshot provided_
(To check their attention to detail)
*the test are to be done in 90 minutes, which is I believe is very plenty
**I only had 1.5 years experience at the time, from working at that company
In that one month period, 9 people applied as front end, 7 are fresh graduates, 2 applied as a "senior" front end developer
... none of them can finish the test
1 "senior", managed to finish 2, but the HR said he's too arrogant, so not preferable
1 freshman managed to work on all of them, but only finished 2, and the code looks better than the one above
In the end, the freshman was hired
Upon my last day, the new hires were assembled to be given a crash course, there were 5 backend devs and 1 front end devs, all of them are fresh graduates, and the boss decided to pay a visit (the devs worked in a different office from the administratives)
Just as I was passing my knowledge to the new guy, I can see that he is really new to coding (he doesn't even know stackoverflow), and I tried my best to be supportive, then the boss suddenly decided to "share" his wisdom, and started talking about how I managed to work on several different projects alone, and how he got new interesting projects in the future and such.
I could see the new guy is getting pale, and his life force seeping out from the top of his head as the flashbacks of his entire life up to that point passes right before his eyes.. Because that is what I felt on my first day joining the company.
But if I could survive that for 16 months -most developer only last a year at most, 14 devs has come and goes during that 16 months- why couldn't he? I passed the Friday of my last day peacefully, and went home for the evening.
2 days later on Sunday, I got a whatsapp message from the HR.
...the new guy sent his resignation yesterday.17
I really want to stress that we should add the ticket for adding the missing test cases in *this* sprint and not postpone it any further.
-- "Isn't there something more important to be added instead?"
There. ALWAYS. Is. Something. MORE. Important. The real problem was that we implement the test cases in the past to begin violating our definition of done. We have to fix and one point and we have to own that decision as nobody else will care about passing tests and test coverage. It's our job to care for that.
Yes, we can instead focus on all the other high-priorities task that should have been done yesterday, yet that won't change the fact that large part our codebase will remain an untested messy blackbox just asking for weird bugs and wild goosechases in the future.
Don't hide behind "high priority tasks". A job is done when it is fucking done and tests are part of that. Hurrying from one important task to the next will just mean we'll never do it. There is no better time than right now.
If code coverage got left behind in the past, then we'll have to suck it up in order to fix it as soon as possible, otherwise we'll just suck forever.1
After writing ~200 lines of code and then unit testing it
THE TESTS ALL PASS!!!
then I run them again just to be sure and they all pass but mocha is saying I am getting 40ms lag on some of my tests...
This is meant to be an async message passing system; I cannot have an input lag of 40ms :(5
How the fuck does php type juggleling evaluate an variable as an integer on my system and passing all tests.
Then on the server as string, failing a typesafe comparison for authentication.8
As always with group projects, one or two people barely do anything and end up getting a passing grade because 1-3 r group members do all the heavy lifting.
Why do they always get away with this? From the two persons that profit from other peoples work in my current project, at least one is trying to make up for it now.
You would hope at least some of the useless group members would have washed out by the end of second year because of tests, but no.
Gonna be fun when everyone has to point out a part of the code made by them, not simply going to let them take credit for my work at least.3
I. Fucking. Hate. Tests.
I am writing a module according to a standard and this standard has a test suite. Awesome...this should make development go pretty smoothly especially since their human-readable "specification" is severely lacking.
I get the module passing most of the tests...however there are few I just can't get my module to pass, no matter what...well fuck.
I go digging deeper into the test cases, compare it to source code. What's this? The tests are fucking wrong. There are several other implementations that use this test suite, how the fuck have they not caught this?
Also come to find out, it is not possible to pass *all* the tests in the suite because some are for older versions that have different functionality.
Got to love a test suite that is incorrect and can't be passed 100%
Maybe they need tests to make sure the tests are working correctly.3
Seeking help from anyone able to read Laptop motherboard semantics sheet
In short: Looking for a blown fuse on Laptop (Dell Inspiron 7547) near LCD cable connector, as not getting backlight after a new screen installation. Screen is functional and is detected properly and the device is passing all the diagnostics tests.
Issue tracked here
How do you think about unit testing/TDD when writing apps? (I'm working this at 3am so might be a bit messy... Just a thought I woke up to).
Whenever I write an app, I don't write unit tests but as I'm developing I may create test functions for specific parts that I run to validate a specific component is working before moving onto the next.
So first, when I get a problem, break it up into components based on the requirements. It's usually sort of input, processor, output sequence.
Where the processor is essentially the core app. And so I start coding it, referring to the input thru an interface, model objects, adding fields as I go along (assume no matter what the input, I will get these before the logic is called). I may add some more interfaces as well for other data I may need but I know won't be going in the first input.
So I write all the logic, functions needed to get a basic app to run that does what I am writing the app for.
Only then do I write a test functions passing in different parameters to make sure the logic and response is what I want and making fixes as necessary. At that point I basically have the simplest version of the app.
(I guess this is sort of like mocking?)
Then build outwards implementing and testing components as I go along and may do some simple refactoring/redesign. (I guess all these tests are functional then, have to start the whole app).
And finally when I have the basic requirements fully complete I will add the "nice to haves" on top via refactoring of specific logic in specific components. Again testing by running the app maybe with simple inputs.
I guess now I'm thinking how do you write unit tests/TDD if the app keeps changing (via adhoc refactorings) as you are creating it?
Over the last few weeks, I've containerised the last of our "legacy" stacks, put together a working proof of concept in a mixture of DynamoDB and K8s (i.e. no servers to maintain directly), passing all our integration tests for said stack, and performed a full cost analysis with current & predicted traffic to demonstrate long term server costs can be less than half of what they are now on standard pricing (even less with reserved pricing). Documented all the above, pulled in the relevant higher ups to discuss further resources moving forward, etc. That as well as dealing with the normal day to day crud of batting the support department out the way (no, the reason Bob's API call isn't working is because he's using his password as the API key, that's not a bug, etc. etc.) and telling the sales department that no, we can't bolt a feature on by tomorrow that lets users log in via facial recognition, and that'd be a stupid idea anyway. Oh, and tracking down / fixing a particularly nasty but weird occasional bug we were getting (race hazards, gotta love 'em.)
Pretty pleased with that work, but hey, that's just my normal job - I enjoy it, and I like to think I do good work.
In the same timeframe, the other senior dev & de-facto lead when I'm not around, has... "researched" a single other authentication API we were considering using, and come to the conclusion that he doesn't want to use it, as it's a bit tricky. Meanwhile passed all the support stuff and dev stuff onto others, as he's been very busy with the above.
His full research amounts to a paragraph which, in summary, says "I'm not sure about this OAuth thing they mention."
Ok, fine, he works slowly, but whatever, not my problem. Recently however, I learn that he's paid *more than I am*. I mean... I'm not paid poorly, if anything rather above market rate for the area, so it's not like I could easily find more money elsewhere - but damn, that's galling all the same.5
Working on a portfolio project - I ran some tests, everything is all good - 100% passing. Computer freezes - pop_os has been giving me shit lately, so I have to restart. Fine.
I get back into code, i re-run pytest - nothing works. Python apparently can't find my modules anymore. I try a few things, nothing. Why? Who the fuck knows - "oh you need this conftest file", "oh you need to remove __init__ from this directory or that one", "oh it's a pytest version iss---" no, no, no - listen here you little shit, it was working two seconds ago. Tell me why and how software I wrote with the most basic ass package structure - literally TWO directories suddenly has no fucking clue how to import the modules. hmm? Even from within the app directory, app.server now no longer recognizes imports from app.main or app.database.
ALL of this worked. It works in new directories without dedicated venvs - it works in new directories with my global python install - it works with any one of my conda envs - it works on other computers - WHY doesn't it work in THIS directory all of a sudden?? Ugh.
What's terrible is that relative imports will probably solve it within the app dir, but the tests dir won't accept them. Moreover, vs code autocompletion can find all the modules, but python itself cannot. Fucking infuriating shit like this is.1