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•9mo ago

Comments

recroad•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo ago
Fail as early as you can, if you can't recover.
just6979•9mo 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•9mo 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•9mo ago
Something's seriously messed up with the font on that page for me.

Voxtral Transcribe 2

https://mistral.ai/news/voxtral-transcribe-2
429•meetpateltech•5h ago•118 comments

Yawning has an unexpected influence on the fluid inside your brain

https://www.newscientist.com/article/2513692-yawning-has-an-unexpected-influence-on-the-fluid-ins...
53•MDWolinski•5d ago•23 comments

How Jeff Bezos Brought Down the Washington Post

https://www.newyorker.com/news/annals-of-communications/how-jeff-bezos-brought-down-the-washingto...
39•thm•1h ago•3 comments

Building a 24-bit arcade CRT display adapter from scratch

https://www.scd31.com/posts/building-an-arcade-display-adapter
56•evakhoury•2h ago•12 comments

Claude Code for Infrastructure

https://www.fluid.sh/
30•aspectrr•1h ago•13 comments

Mean People Fail (2014)

https://paulgraham.com/mean.html
21•insuranceguru•36m ago•25 comments

Attention at Constant Cost per Token via Symmetry-Aware Taylor Approximation

https://arxiv.org/abs/2602.00294
126•fheinsen•5h ago•65 comments

Claude Code: connect to a local model when your quota runs out

https://boxc.net/blog/2026/claude-code-connecting-to-local-models-when-your-quota-runs-out/
9•fugu2•3d ago•1 comments

AI is killing B2B SaaS

https://nmn.gl/blog/ai-killing-b2b-saas
46•namanyayg•3h ago•53 comments

Tractor

https://incoherency.co.uk/blog/stories/tractor.html
91•surprisetalk•23h ago•29 comments

Arcan-A12: Weaving a Different Web

https://www.divergent-desktop.org/blog/2026/01/26/a12web/
28•ingenieroariel•4h ago•6 comments

RS-SDK: Drive RuneScape with Claude Code

https://github.com/MaxBittker/rs-sdk
58•evakhoury•3h ago•22 comments

Converge (YC S23) Is Hiring Product Engineers (NYC, In-Person)

https://www.runconverge.com/careers/product-engineer
1•thomashlvt•3h ago

A sane but bull case on Clawdbot / OpenClaw

https://brandon.wang/2026/clawdbot
197•brdd•1d ago•324 comments

Claude Is a Space to Think

https://www.anthropic.com/news/claude-is-a-space-to-think
225•meetpateltech•8h ago•112 comments

Study: emotional support from social media found to reduce anxiety

https://news.uark.edu/articles/80669/emotional-support-from-social-media-found-to-reduce-anxiety
50•giuliomagnifico•3h ago•51 comments

2 in 5 Americans did not read a single book in 2025

https://mybooklist.club/reading-statistics
16•BigBalli•2h ago•5 comments

Coding Agent VMs on NixOS with Microvm.nix

https://michael.stapelberg.ch/posts/2026-02-01-coding-agent-microvm-nix/
61•secure•3d ago•31 comments

A case study in PDF forensics: The Epstein PDFs

https://pdfa.org/a-case-study-in-pdf-forensics-the-epstein-pdfs/
189•DuffJohnson•5h ago•93 comments

Old Insurance Maps – Georeferencing Sanborn Fire Insurance Maps on Modern Maps

https://oldinsurancemaps.net/
67•lapetitejort•1w ago•18 comments

Show HN: Ghidra MCP Server – 110 tools for AI-assisted reverse engineering

https://github.com/bethington/ghidra-mcp
243•xerzes•13h ago•61 comments

Guinea worm on track to be 2nd eradicated human disease; only 10 cases in 2025

https://arstechnica.com/health/2026/02/guinea-worm-on-track-to-be-2nd-eradicated-human-disease-on...
181•bookofjoe•5h ago•77 comments

AI needs to augment rather than replace humans or the workplace is doomed

https://www.theguardian.com/technology/2026/jan/25/ai-augment-rather-than-replace-workplace-doomed
41•PaulHoule•2h ago•17 comments

FBI couldn't get into WaPo reporter's iPhone because Lockdown Mode enabled

https://www.404media.co/fbi-couldnt-get-into-wapo-reporters-iphone-because-it-had-lockdown-mode-e...
479•robin_reala•5h ago•394 comments

I miss thinking hard

https://www.jernesto.com/articles/thinking_hard
1162•jernestomg•16h ago•632 comments

Show HN: SymDerive – A functional, stateless symbolic math library

17•dinunnob•3d ago•3 comments

Brazilian Micro-SaaS Map

https://saas-map.ssr.trapiche.cloud/
83•acfilho•3d ago•4 comments

The Great Unwind

https://occupywallst.com/yen
175•jart•2h ago•129 comments

Data centers in space makes no sense

https://civai.org/blog/space-data-centers
1000•ajyoon•1d ago•1160 comments

High-Altitude Adventure with a DIY Pico Balloon

https://spectrum.ieee.org/explore-stratosphere-diy-pico-balloon
99•jnord•3d ago•48 comments