Appendix C — Procedure Behavior Tests

This manual is still under development and may be subject to change.

This warning will be removed once the manual is finalized.

This document provides unit tests for the LogoClim NetLogo model. The tests validate procedure behavior and arguments to ensure correct model functionality.

C.1 Problem

Procedures can produce unexpected results and have side effects that may not be captured during the development process. This document addresses these challenges by providing pre-defined expectations for each procedure’s behavior.

C.2 Methods

C.2.1 NetLogo Integration

Integration with NetLogo (Wilensky, 1999) is facilitated by the logolink R package (Vartanian, 2026b). This package enables the execution of BehaviorSpace experiments directly from R.

Outputs were extracted in Table and Lists format, along with metadata about the model’s settings.

No Java dependencies are required. NetLogo bundles its own Java Runtime Environment (JRE), ensuring independent operation regardless of the system’s Java installation.

C.2.2 Continuous Integration

These tests use the latest release of NetLogo and are automated using GitHub Actions provided by the LogoActions project (Vartanian, 2026a). Each commit to the code repository triggers test execution, ensuring that errors are caught early in the development process.

C.2.3 Expectation Tests

Expectations were validated using the testthat and checkmate (lang2017?) R packages.

C.2.4 Code Style

The Tidyverse Tidy Tools Manifesto (Wickham, 2023), code style guide (Wickham, n.d.-a) and design principles (Wickham, n.d.-b) were followed to ensure consistency and enhance readability.

C.2.5 Reproducibility

The pipeline is fully reproducible and can be run again at any time. To ensure consistent results, the renv package (Ushey & Wickham, 2025) was used to manage and restore the R environment. See the README file in the code repository to learn how to run it.

C.3 Set the Environment

C.3.1 Load Packages

Code
library(cli)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(here)
library(logolink)
library(magrittr)
library(testthat)
#> 
#> Attaching package: 'testthat'
#> The following objects are masked from 'package:magrittr':
#> 
#>     equals, is_less_than, not

C.3.2 Set Initial Variables

Setting the JAVA_TOOL_OPTIONS is optional, but recommended to avoid unnecessary messages from the Java Media Framework.

Code
Sys.setenv(JAVA_TOOL_OPTIONS = "-Dcom.sun.media.jai.disableMediaLib=true")
Code
model_path <- here("nlogox", "logoclim.nlogox")

C.4 single-quote

Code
setup_file <- create_experiment(
  name = "single-quote",
  setup = "setup false",
  metrics = c(
    'single-quote 1',
    'single-quote [1 2 3]'
  )
)
Code
results <-
  model_path |>
  run_experiment(
    setup_file = setup_file
  )
#> ℹ Running model
#> ✔ Running model [6s]
#> 
#> ℹ Gathering metadata
#> ✔ Gathering metadata [36ms]
#> 
#> ℹ Processing table output
#> ✔ Processing table output [28ms]
#> 
#> ℹ The experiment run produced the following messages:
#> 
#> Picked up JAVA_TOOL_OPTIONS: -Dcom.sun.media.jai.disableMediaLib=true
Code
results |>
  extract2("table") |>
  pull(single_quote_1) |>
  expect_equal("'1'")
Code
results |>
  extract2("table") |>
  pull(single_quote_1_2_3) |>
  expect_equal("['1' '2' '3']")