Local LLM Field Notes Hutaff Studios
Benchmarks · December 5, 2026 · 9 min read

Can an LLM write unit tests as effective as human-written ones?A comparison against NASA's own tests for its flight software

Two Claude models and three local models wrote unit tests for NASA's core Flight System. I measured each test file exactly as I measured NASA's own hand-written file for the same source.

NASA cFS · C · UT-Assert Claude Qwen Gemma LM Studio M4 Max · 64 GB
Bottom line

Yes. The strongest models now write unit tests as effective as the ones NASA's engineers wrote for the same code.

Across 22 source files of flight software, Claude's test files matched or exceeded NASA's on about nine files in ten. The best local model managed just over half. Everything below is the evidence, and the caveats.

91%
Claude Sonnet 5.5 matched or exceeded NASA's tests on 20 of 22 files.Opus 5.5 did it on 11 of the 12 files it ran. Every miss was by one fault, or one file that never passed.
57%
Qwen4, running on a laptop, did it on 8 of 14 files.When it produced a passing file, that file was at NASA's level 8 times out of 9. Its problem was producing one.
1 of 20
Gemma 4 could not do it.Most of its attempts did not compile against the test framework. One file passed across two builds.
85% vs 68%
Coverage hides the difference. Fault detection shows it.Share of 523 planted faults detected on the same 22 files: Sonnet's tests, then NASA's. NASA's files all have 100% coverage.
5 of 22
Nobody one-shots it.That is how many files Sonnet got right on the first attempt. Opus managed 4 of 12 and Qwen4 none. A repair loop is required.
$1.14
per file with Sonnet, in about six minutes.Qwen4 costs nothing per file and takes three to four times as long. On a 64 GB machine it could not fit the largest files.

Share of attempted files where the model's tests were at least as effective as NASA's

Claude Opus 5.592% 11 of 12 files attemptedClaude Sonnet 5.591% 20 of 22 files attemptedQwen4 35B57% 8 of 14 files attemptedGemma 26B 8-bit10% 1 of 10 files attemptedGemma 26B 6-bit0% 0 of 10 files attempted
ClaudeLocal model
The models attempted different numbers of files, so the bars show percentages. A stricter count that also requires 100% line and branch coverage, as NASA's files have, gives Sonnet 19 of 22, Opus 10 of 12, Qwen4 4 of 14 and Gemma none.

What “at least as effective” means. The model's test file builds, passes against the real source, and detects at least as many planted faults as NASA's file for the same source. That last measure is mutation testing: plant a small fault, re-run the tests, see whether anything fails.

One more angle, kept separate. I also put 15 real bugs from the project's history back into the code. Sonnet's tests detected 13 and NASA's 7. That is a narrower question than the one in the title, and it has its own section.

Why NASA's code

It is easy to ask a model for unit tests and get something that compiles and turns green. The useful question is whether those tests are as good as the ones a careful engineer would have written for the same code.

NASA's core Flight System (cFS) makes that question answerable. It is open source, written in C, flown on real missions, and ships with a hand-written unit test file for nearly every source file. So for any source file there is a human-written test file to compare against, written by the people who own the code.

What was measured

Every test file, whether a model wrote it or NASA did, goes through the same three measurements.

  1. Does it build and pass? The file is compiled in a container with warnings as errors, then run against the real source.
  2. How much does it cover? Line and branch coverage of the file under test. NASA's tests reach 100% of both on every file used here.
  3. How many faults does it detect? Small faults are planted in the source one at a time: a flipped comparison, a dropped assignment, a removed function call. The tests are re-run, and if any check fails the fault is detected. This is mutation testing, a standard way to measure how strong a test suite is, as opposed to how much code it touches.

I count a model's test file as at least as effective as NASA's when it builds, passes, and detects at least as many planted faults as NASA's file for the same source. Coverage is reported next to that, and I also give a stricter count that requires full coverage.

How the models were run

Claude Opus 5.5Anthropic API · adaptive thinking, high effortReplies up to 128,000 tokens
Claude Sonnet 5.5Anthropic API · adaptive thinking, high effortReplies up to 128,000 tokens
Qwen4 35B-A3BGGUF Q4_K_M · 37 GB · llama.cpp (Metal)131k context · no reply cap · 30 min per attempt
Gemma 4 26B-A4B, 8-bitMLX · 28 GB131k context · 30 min per attempt
Gemma 4 26B-A4B, 6-bitMLX · 22 GB131k context · 30 min per attempt
UT
NASA's own testsThe unit tests that ship with cFSThe baseline every model is scored against

Result one: ten files, five models

Ten source files from two cFS apps, Housekeeping (HK) and Memory Dwell (MD), with 244 planted faults between them. All five models attempted all ten.

Test files at least as effective as NASA's, out of 10

Claude Opus 5.59 of 10 filesClaude Sonnet 5.58 of 10 filesQwen4 35B4 of 10 filesGemma 26B 8-bit1 of 10 filesGemma 26B 6-bit0 of 10 files
ClaudeLocal model
A file counts when it builds, passes, and detects at least as many planted faults as NASA's test file for the same source.

Planted faults detected, out of 244

Claude Opus 5.5229 of 244 · 10 of 10 files passClaude Sonnet 5.5197 of 244 · 9 of 10 files passNASA's own tests179 of 244 · the baselineQwen4 35B94 of 244 · 5 of 10 files passGemma 26B 8-bit24 of 244 · 1 of 10 files passGemma 26B 6-bit0 of 244 · no file passes
NASA's own testsClaudeLocal model
The same ten files, totalled. A file that never built or never passed contributes zero. Some planted faults cannot be detected by any test, because the edit does not change behaviour, so 100% is not reachable.

Planted faults detected, by file

Source filePlanted faultsNASAOpus 5.5Sonnet 5.5Qwen4Gemma 8-bit
hk_app.c282628failedfailedfailed
hk_cmds.c1210121212failed
hk_dispatch.c28242826failedfailed
hk_utils.c24182323out of memoryfailed
md_app.c26162321failedfailed
md_cmds.c2614222220failed
md_dispatch.c25202222failedfailed
md_dwell_pkt.c2615262623failed
md_dwell_tbl.c2312222216failed
md_utils.c262423232324
A number is the count of planted faults detected by a passing test file. “Failed” means no attempt both built and passed. Qwen4 ran out of memory on hk_utils.c during a repair round.

Opus produced a passing file for all ten sources. Nine detected more faults than NASA's file; the tenth, for md_utils.c, was one fault short. Sonnet matched or exceeded NASA's on eight. It was one fault short on the same file and never got hk_app.c to pass.

Qwen4 passed five files. Four of them matched or exceeded NASA's and the fifth was one fault short. Of the other five, four never passed and one ran out of memory. No Qwen4 file passed on its first attempt.

Gemma 4 struggled with the framework itself. The 8-bit build passed one file, which tied NASA's. The 6-bit build passed none, and only two of its thirty attempts compiled.

On coverage, NASA's files reach 100% of lines and branches everywhere. So did 9 of Opus's 10 passing files, 8 of Sonnet's 9 and 3 of Qwen4's 5. The rest came within a few percent.

Result two: twelve larger files

A second set of 12 source files from six other apps (CF, CS, DS, FM, HS and SC), with 279 planted faults. These files are larger, and here the style example came from a different app, so the model saw no NASA test file from the app it was testing.

Not every model ran every file. Sonnet ran all twelve. Opus ran two before my API credit ran out. Qwen4 ran the four whose prompts fit its context window on this machine.

Planted faults detected on the second set, by file

Source filePlanted faultsNASASonnet 5.5Opus 5.5Qwen4
cf_chunk.c25161717too large
cf_codec.c19151818too large
cs_compute.c231823not runtoo large
cs_table_processing.c251625not runtoo large
ds_app.c261823not run20
fm_app.c251425not runtoo large
fm_cmds.c241018not runtoo large
hs_app_monitor.c241621not run19
hs_event_monitor.c241721not run18
hs_exec_monitor.c211116not run16
sc_app.c221120not runtoo large
sc_atsrq.c211321not runtoo large
“Too large” means the prompt left little or no room for a reply inside Qwen4's 131,072-token window, so I did not attempt it. “Not run” means the Opus run had stopped. Totals: Sonnet 248 of 279 against NASA's 175. On Qwen4's four files: Qwen4 73 of 95, NASA 62, Sonnet 81.

Every file that was attempted in this set passed, and every one detected at least as many faults as NASA's. Sonnet's twelve files all reached full line and branch coverage. Qwen4's four passed with full coverage on two.

Put the two sets together and you get the chart at the top of this post: Sonnet at 20 of 22 files, Opus at 11 of 12, Qwen4 at 8 of 14.

Another angle: would the tests catch a real bug coming back?

Planted faults measure the general strength of a test file. A separate question is whether it would notice a specific, real bug returning. This is a narrower test, and it needs a caveat up front: the models wrote their tests against today's corrected code. So it shows whether a test file pins down correct behaviour firmly enough to flag an old bug. It does not show that a model would have found that bug in the first place.

To get real bugs I went through the full history of cFS and its apps. Take a commit that fixed a bug, un-apply it to today's code so the bug is back, rebuild, and see which tests notice. Most commits do not survive that treatment.

From 4,408 commits to 42 usable bugs

Commits in the history of 17 repositories4,408 …that change flight code1,622 …and are small (40 lines, 3 files or fewer)1,029 …and can be un-applied to today's code247 …and still compile204 …and change the compiled code of a tested file125 …and are real bug fixes, by my reading42
Compiled code was compared before and after each un-applied change, to drop changes that had no effect on this build. The last step is a judgement call: I read each remaining diff and kept only changes that fix wrong behaviour, setting aside refactors, hardening and deliberate behaviour changes.

That left 42 real bug fixes across ten components. This round uses 13 of them, the ones in the twelve files of the second set. One HS fix touched three files and is scored once per file, so the charts below count 15 bugs.

Real bugs detected on all 12 files, out of 15

Claude Sonnet 5.513 of 15NASA's own tests7 of 15
NASA's own testsClaude
Sonnet only, because it is the one model that ran all twelve files. On Opus's two files it detected 2 of 2 real bugs, where NASA's tests detect 1.

Real bugs detected on the four files Qwen4 ran, out of 7

Claude Sonnet 5.56 of 7Qwen4 35B5 of 7NASA's own tests3 of 7
NASA's own testsClaudeLocal model
ds_app.c and the three HS monitor files.

Every real bug, and which test files detected it

FileNASASonnet 5.5Opus 5.5Qwen4FixedWhat the fix did
cf_codec.cmissedcaughtcaughttoo large2023-10
Decoding segs using incorrect macro
cf_chunk.ccaughtcaughtcaughttoo large2026-09
Ignore empty ranges in CF_ChunkListAdd
cs_table_processing.cmissedcaughtnot runtoo large2026-03
Adjust buffer termination
cs_compute.ccaughtcaughtnot runtoo large2026-11
App checksum handling after restart
ds_app.ccaughtcaughtnot runcaught2023-03
Change EVS_Register failure from SendEvent to WriteToSysLog
ds_app.cmissedmissednot runmissed2023-03
Remove file age check bug
ds_app.ccaughtcaughtnot runcaught2024-07
Prevent DS app exit on CFE_SB_NO_MESSAGE
ds_app.ccaughtcaughtnot runcaught2026-11
Use RunStatus to guard fatal exit diagnostics
fm_app.ccaughtcaughtnot runtoo large2023-03
Change EVS_Register failure from SendEvent to WriteToSysLog
fm_cmds.cmissedmissednot runtoo large2026-07
Add Null Terminator for FileName in FM_GetDirListFileCmd
hs_app_monitor.cmissedcaughtnot runcaught2026-09
Accept the highest valid action type (off-by-one check)
hs_event_monitor.cmissedcaughtnot runmissed2026-09
Accept the highest valid action type (off-by-one check)
hs_exec_monitor.cmissedcaughtnot runcaught2026-09
Use the right loop limit when refreshing execution counters
sc_atsrq.ccaughtcaughtnot runtoo large2023-10
Add extra range checking
sc_app.cmissedcaughtnot runtoo large2026-04
Add check for CFE_SB_NO_MESSAGE
“Caught” means at least one check failed when the bug was put back. “Too large” and “not run” are as in the table above.

This angle agrees with the first. Sonnet's tests detected every real bug that NASA's detect, plus six more, and the two they missed are ones NASA's also miss. Qwen4's detected two that NASA's miss, and missed one that Sonnet's caught.

Here is what a detection looks like. One HS fix changed a boundary check that had been rejecting the last valid action type:

/* hs_app_monitor.c, with the old bug put back */
+    else if (ActionType >= (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES))
-    else if (ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES))

NASA's tests pass with the bug in place. Sonnet's fail, because one of its tests validates a table that uses the highest valid action type:

[ FAIL] hs_app_monitor_tests.c:537
        HS_AppMon_ValidateTable(Table) (-1) == CFE_SUCCESS (0)
[ FAIL] hs_app_monitor_tests.c:540
        context_CFE_EVS_SendEvent[0].EventID (51) == HS_AMTVal_INF_EID (50)

I re-ran seven of Sonnet's files in a separate build and read the failing checks for each detection. All were specific assertions like these. None was a crash or a timeout.

Why would NASA's tests miss real bugs?

This is less damning than it sounds. A bug that reached the repository is, almost by definition, one the tests of the day did not catch. The question here is whether today's tests would catch it if it came back, and for 8 of 15 they would not.

NASA's tests reach 100% line and branch coverage on all 12 files. So they execute the buggy lines, but do not check closely enough what those lines produce. The models' tests tend to assert more: exact return codes, event IDs, call counts.

Time and cost

Effort by run

RunFiles passingPassed first tryFull coverageTimeAPI cost
Opus 5.5 · 10 HK/MD files10 of 103963 min$14.98
Sonnet 5.5 · 10 HK/MD files9 of 102840 min$7.86
Qwen4 · 10 HK/MD files5 of 1003115 min for 9none
Gemma 8-bit · 10 HK/MD files1 of 1000332 minnone
Gemma 6-bit · 10 HK/MD files0 of 100075 minnone
Sonnet 5.5 · 12 real-bug files12 of 1231291 min$17.15
Opus 5.5 · 2 real-bug files2 of 21213 min$5.19
Qwen4 · 4 real-bug files4 of 40266 minnone
Time is model time summed over attempts. “Full coverage” means 100% of lines and branches in a passing file. Qwen4's HK/MD time covers the nine files that finished. Local runs cost electricity only.

The hosted models are fast and not free. The twelve files of the second set cost $17.15 with Sonnet, about $1.43 a file, because each prompt carries the app's headers and the replies run long. Opus cost about twice as much per file on the first set.

Qwen4 costs nothing per file and takes about four times as long on the files both finished. Its hard limit was memory. A cFS app's headers plus a long test file plus a repair round is a lot of context, and on a 64 GB machine that is where runs stopped. A machine with more memory should fit more of the files. I have not tested that.

Method and limits