Skip to content
#software testing Open access

Testing NetLogo model code

Oct 2026 · Ecological Modelling · 0 citations · 24 references

TL;DR

This work identifies eight kinds of errors that are especially common in NetLogo software and presents code testing methods appropriate for models implemented in NetLogo by novice programmers.

Abstract

In simulation modeling, good code testing practices provide (a) efficiency, by reducing time wasted using erroneous software; (b) credibility, by providing evidence that important errors are unlikely; and (c) understanding, by showing how complex model results arose. However, code testing receives little attention in agent-based modeling, and many modeling projects have been derailed by undetected code errors. We present code testing methods appropriate for models implemented in NetLogo by novice programmers. An efficient cycle for implementing new models includes: drafting a written model description and testing the “ submodels ” that each represent a separate process, coding the model while updating the written description to correct ambiguities and errors, and then thorough code testing. As the model is then used and revised, the written description, code, and code tests are all updated. We identify eight kinds of errors that are especially common in NetLogo software. Logic errors are the hardest to detect; doing so typically requires producing detailed test output for key sub-models and then analyzing that output for unexpected results. We provide methods for producing test output, with example NetLogo code. Test output can be analyzed graphically, statistically, by tracing the fate of individual agents, or by comparing it to an independent implementation of the submodel. When unexpected results are found, a variety of “ debugging ” methods help determine whether they are caused by software errors and, if so, where the errors are. Documenting code testing methods and results is also key to model credibility and efficiency: documented tests provide evidence that the code is reasonably error-free and makes it easier to repeat tests as models are revised. While NetLogo currently lacks code-testing tools such as stepwise debuggers and unit testers, its powerful commands make it easy to add similar capabilities to models.

Read PDF

Similar papers

Preprint Aug 2026

Unreliable in Practice? A Comprehensive Study of Errors in LLM-Generated Code

It is observed that generated code often omits basic input validation or memory-safety checks, which can lead to overflows, resource exhaustion, or other reliability/security issues, and even the largest models frequently make simple mistakes.

Rodrigo Pato Nogueira, Marco Vieira, João R. Campos · 0 citations
Preprint Jul 2026

Specula: Scaling formal specifications for autonomous model checking of system code

Specula is a push-button agentic system that generates high-quality formal specifications for large, complex system code and uses the specifications for highly effective model checking and bug finding. Specula employs large language model (LLM) based coding agents to autonomously develop TLA+ specifications, including invariants that describe correctness properties of the target system and formal models that describe the system implementation with the right level of abstractions. Specula is fully autonomous and thus eliminates the barrier of applying formal methods to real-world system code (as in traditional human-centric approaches). Meanwhile, Specula addresses limitations of LLM-driven techniques like reward hacking and hallucinations through self-evolving loops that iteratively improve specification quality by enabling the agents to deepen their understanding of system code and its behaviors. We have used Specula to check 48 open-source system projects; Specula found 249 bugs including many deep bugs that are hard to find by existing approaches. Specula has been used by several companies and is maintained at https://github.com/specula-org/Specula.

Q. Cheng, Saad Mohammad Rafid Pial, Ruize Tang et al. · 0 citations
Preprint Jul 2026

On the risk of coding before testing: An empirical study on LLM-based test generation workflow

This paper introduces and empirically study the phenomenon of error propagation, where faults in generated code are systematically replicated in associated test artifacts, and examines whether LLM-generated code biases the generation of subsequent tests.

Michael Konstantinou, Florian Tambon, Mike Papadakis · 1 citation
Review Aug 2026

Combining Tests and Proofs with Contracts for Better Software Verification

Three applications, leveraging on the mechanisms of Eiffel and design by contract, hold significant promise to address some of the challenges of program testing, software maintenance, and automatic program repair.

Li Huang, Bertrand Meyer, M. Oriol · 0 citations
Preprint Jul 2026

Specification Grounding Drives Test Effectiveness for LLM Code

Large language models frequently generate code that appears correct on typical inputs yet fails on edge cases, invalid inputs, and other specification-defined corner conditions, so a single prompt line is changed that controls whether the tester receives the spec as a checklist of rules.

Amin Haeri, Mahdi Ghelichi · 0 citations

Related blog posts

MIT News · Artificial Intelligence Aug 17, 2026

Q&A: Rethinking how innovation happens

In his latest book, Professor Eugene Fitzgerald examines the forces that turn breakthroughs into value — and why innovation resists simple formulas.