frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Using tests as a debugging tool for logic errors

https://www.qodo.ai/blog/java-unit-testing-how-to-use-tests-as-a-debugging-tool-for-logic-errors/
38•simplesort•8mo ago

Comments

recroad•8mo ago
This article seems like a very long-winded and complicated way to say that we should write tests. Am I missing something here? Wouldn't most developers write tests when creating algorithms, let alone something relating to finance as tax calculations? Yes, you should reproduce a defect by writing a failing tests first.

Where I hoped/thought this piece would go was to expand on the idea of error-prone[1] and apply it to the runtime.

https://github.com/google/error-prone

simplesort•8mo ago
I thought it was interesting - not revolutionary but updated my thinking a bit.

Writing a failing test that reproduces a bug is something I learned pretty early on.

But I never consciously thought about and approached the test as a way to debug. I thought about it more of a TDD way - first write tests, then go off and debug/code until the test is green. Also practically, let's fill the gap in coverage and make sure this thing never happens again, especially if I had to deal with it on the weekend.

What was interesting to me about this was actively approaching the test as a way of debugging, designing it to give you useful information and using the test in conjunction with debugger

whynotmaybe•8mo ago
I'm happy for you that you learned something and sad for me because you made me feel old and stupid.

I tend to forget that people don't know stuff I learned decades ago and consider them as general knowledge.

Before TDD became what it was, we used to create specific files for specific bug cases, or even get the files from the users themselves.

JadeNB•8mo ago
> I tend to forget that people don't know stuff I learned decades ago and consider them as general knowledge.

While all of us who are lucky to be around long enough meet the problem of general knowledge changing under our feet, it's hard for me to imagine how saying this to someone can be a productive contribution to the conversation. What can it accomplish other than making someone feel worse for not knowing something that you consider general knowledge?

whynotmaybe•8mo ago
I don't think anyone should feel bad for not knowing something.

My "general" knowledge is built on my experience.

The first comment before OP answer's was kinda condescending about the article and I felt the same way when reading it but then op's comment made me realise I was in the wrong because I forgot that my "general" knowledge is not general at all.

OP had to defend why he posted it. I wanted to tell OP that it was a good idea to post it, not for the article content, but for my teaching moment.

Jtsummers•8mo ago
> What was interesting to me about this was actively approaching the test as a way of debugging, designing it to give you useful information and using the test in conjunction with debugger

I'm curious, if you're using TDD weren't you already doing this? A test that doesn't give you useful information is not a useful test.

hyperpape•8mo ago
I think the distinction is that if you write a test that reproduces the bug, that's a binary signal and doesn't by itself tell you anything about why the bug is happening.

In contrast, if you write tests that rule out particular causes of a bug you're incrementally narrowing down the potential causes of the bug. So each test gives you information that helps you solve the bug, without directly stepping through the code.

Unfortunately, I don't think the post is a great primer on the subject.

Jtsummers•8mo ago
> Unfortunately, I don't think the post is a great primer on the subject.

It isn't, nor is it intended to be. It's an advert:

>> While mastering unit tests as debugging tools takes practice, AI-powered solutions like Qodo can significantly accelerate this journey. Qodo’s contextual understanding of your Java codebase helps it automatically generate tests that target potential logic vulnerabilities.

gavmor•8mo ago
> then go off and debug/code until

Yes, this is a missed opportunity! Well said. I try to write tests in place of print statements or debuggers, using assertions like xray glasses. Fun times!

jeremyscanvic•8mo ago
This reminds me of a talk that Leslie Lamport (author of LaTeX & prominent figure in the field of distributed computing) gave recently [1]. I remember him arguing that the difficult part in writing code is not to determine what code to write to compute something, but to determine what this something is in the first place. "Logic errors" are really about valid algorithms that end up computing the wrong thing - they're gonna compile, they're gonna run, but they won't do what you want them to do.

One example he gives is computing the maximum element in a sequence of numbers. This is something trivial to implement but you need to decide what to do with the obvious edge case: empty sequences. One solution is to return some kind of error or exception, but another is to extend what we mean by the largest element in a sequence the way mathematicians typically do. Indeed, the maximum function can be extended for empty sequences by letting max([]) := -infinity, the same way empty sums are often defined as 0, and empty products as 1. The alleged benefit of following the second approach is that it should lead to simpler code/algorithms, but it also requires more upfront thinking.

[1] https://www.youtube.com/watch?v=tsSDvflzJbc

pkoird•8mo ago
Closely related are in-code assertions. I remember when I used to liberally use asserts inside a code (and you could disable them for production) to check pre-conditions, post-conditions, or any invariants. Nowadays, I don't think the pattern is recommended anymore, at least in certain popular languages.
esafak•8mo ago
Fail as early as you can, if you can't recover.
just6979•8mo ago
It's not recommended as much anymore because of unit tests. Instead of peppering the code with asserts, you build tests based on those assertions. You don't have to worry about turning it off in production because the tests are separate, and you also don't have to worry about manually triggering all the various asserts in a dev build, because the test runs are doing that for you even before a build is published.
pfdietz•8mo ago
How do you determine if your tests are good at finding logic errors?

Mutation testing. Introduce artificial logic errors and see if your tests find them.

Disappointed the article didn't go into this. You can even use mutation as part of a test generator, saving the (minimized) first test input that kills a mutant. You still need some way of determining what the right answer was (killing the mutant just involves seeing it does something different from the unmutated program.)

codr7•8mo ago
Something's seriously messed up with the font on that page for me.

Antirender: remove the glossy shine on architectural renderings

https://antirender.com/
1617•iambateman•20h ago•398 comments

NASA's WB-57 crash lands at Houston

https://arstechnica.com/space/2026/01/one-of-nasas-three-wb-57-aircraft-just-did-a-belly-landing-...
74•verzali•3d ago•21 comments

We have ipinfo at home or how to geolocate IPs in your CLI using latency

https://blog.globalping.io/we-have-ipinfo-at-home-or-how-to-geolocate-ips-in-your-cli-using-latency/
120•jimaek•7h ago•37 comments

CPython Internals Explained

https://github.com/zpoint/CPython-Internals
25•yufiz•4d ago•0 comments

Guix System First Impressions as a Nix User

https://nemin.hu/guix.html
62•todsacerdoti•5h ago•13 comments

Quaternion Algebras

https://jvoight.github.io/quat.html
51•teleforce•4d ago•19 comments

Show HN: I trained a 9M speech model to fix my Mandarin tones

https://simedw.com/2026/01/31/ear-pronunication-via-ctc/
350•simedw•15h ago•111 comments

Nvidia's 10-year effort to make the Shield TV the most updated Android device

https://arstechnica.com/gadgets/2026/01/inside-nvidias-10-year-effort-to-make-the-shield-tv-the-m...
41•qmr•1h ago•26 comments

My Ridiculously Robust Photo Management System (Immich Edition)

https://jaisenmathai.com/articles/my-ridiculously-robust-photo-management-system-immich-edition/
127•jmathai•3d ago•51 comments

Euro firms must ditch Uncle Sam's clouds and go EU-native

https://www.theregister.com/2026/01/30/euro_firms_must_ditch_us/
504•jamesblonde•6h ago•440 comments

Sumerian Star Map Recorded the Impact of an Asteroid (2024)

https://archaeologyworlds.com/5500-year-old-sumerian-star-map-recorded/
105•griffzhowl•9h ago•35 comments

A Step Behind the Bleeding Edge: A Philosophy on AI in Dev

https://somehowmanage.com/2026/01/22/a-step-behind-the-bleeding-edge-monarchs-philosophy-on-ai-in...
105•Ozzie_osman•2d ago•41 comments

US reportedly investigate claims that Meta can read encrypted WhatsApp messages

https://www.theguardian.com/technology/2026/jan/31/us-authorities-reportedly-investigate-claims-t...
117•echelon_musk•3h ago•96 comments

Insane Growth Goldbridge (YC F25) Is Hiring a Forward Deployed Engineer

https://www.ycombinator.com/companies/goldbridge/jobs/78gGEHh-forward-deployed-engineer
1•alvinsalehi•4h ago

Peerweb: Decentralized website hosting via WebTorrent

https://peerweb.lol/
309•dtj1123•19h ago•107 comments

Moltbook

https://www.moltbook.com/
1587•teej•1d ago•740 comments

"Giving up upstream-ing my patches & feel free to pick them up"

https://mail.openjdk.org/pipermail/hotspot-dev/2026-January/118080.html
22•csmantle•5h ago•9 comments

Implementing the Transcendental Functions in Ivy

https://commandcenter.blogspot.com/2026/01/implementing-transcendental-functions.html
19•chmaynard•5d ago•1 comments

HTTP Cats

https://http.cat/
476•surprisetalk•1d ago•79 comments

Show HN: Phage Explorer

https://phage-explorer.org/
101•eigenvalue•11h ago•22 comments

An anecdote about backward compatibility

https://blog.plover.com/2026/01/26/#wrterm
70•speckx•4d ago•15 comments

Surely the crash of the US economy has to be soon

https://wilsoniumite.com/2026/01/27/surely-it-has-to-be-soon/
434•Wilsoniumite•1d ago•544 comments

Kimi K2.5 Technical Report [pdf]

https://github.com/MoonshotAI/Kimi-K2.5/blob/master/tech_report.pdf
345•vinhnx•23h ago•132 comments

Naples' 1790s civil war was intensified by moral panic over Real Analysis (2023)

https://lareviewofbooks.org/article/foundational-anxieties-modern-mathematics-and-the-political-i...
80•OgsyedIE•12h ago•19 comments

Disrupting the largest residential proxy network

https://cloud.google.com/blog/topics/threat-intelligence/disrupting-largest-residential-proxy-net...
193•cdrnsf•2d ago•186 comments

CERN accepts $1B in private cash towards Future Circular Collider

https://physicsworld.com/a/cern-accepts-1bn-in-private-cash-towards-future-circular-collider/
88•zeristor•6h ago•63 comments

Designing a Passively Safe API

https://www.danealbaugh.com/articles/passively-safe-apis
53•dalbaugh•4d ago•15 comments

Show HN: SF Microclimates

https://github.com/solo-founders/sf-microclimates
44•weisser•5d ago•35 comments

The engineer who invented the Mars rover suspension in his garage [video]

https://www.youtube.com/watch?v=QKSPk_0N4Jc
360•UltraSane•4d ago•54 comments

Archyl – The modern platform for C4 model documentation

https://www.archyl.com/
19•eko•4d ago•5 comments