% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verify.R
\name{verify.stockflow}
\alias{verify.stockflow}
\title{Verify unit tests against simulation results}
\usage{
\method{verify}{stockflow}(object, test = NULL, ...)
}
\arguments{
\item{object}{An \code{\link{stockflow}} object.}

\item{test}{Integer vector of test number(s) to run (numbers-based, as shown by \code{\link[=unit_tests]{unit_tests()}}).
Defaults to \code{NULL} (run all tests).}

\item{...}{Additional arguments passed to \code{\link[=sim_settings]{sim_settings()}} (e.g., \code{seed},
\code{dt}).}
}
\value{
An object of class \code{verify_stockflow}, returned invisibly. Use
\code{\link[=as.data.frame]{as.data.frame()}} to extract results as a data frame and \code{\link[=plot]{plot()}} to
visualize the simulations used. The object contains:
\describe{
\item{results}{List of test result entries, one per test (including inactive
tests, which appear with \code{status = "skip"}). Each entry has \code{label},
\code{expr_str}, \code{conditions}, \code{status}, \code{error_type}, \code{message}, and \code{outcome}.}
\item{object}{The \code{stockflow} model the tests were run against.}
\item{sims}{Nested list of \code{simulate_stockflow} objects used internally by
\code{\link[=plot.verify_stockflow]{plot.verify_stockflow()}}. Always present (never \code{NULL}).}
\item{condition}{Named integer vector mapping each test label to its condition
index. Used internally by \code{\link[=plot.verify_stockflow]{plot.verify_stockflow()}}.}
\item{n_conditions}{Number of unique simulation conditions.}
\item{test_indices}{Integer vector of the original 1-based test numbers that
were run (as shown by \code{\link[=unit_tests]{unit_tests()}}). Equal to \code{seq_along(results)} when
\code{test = NULL} (all tests run).}
}
}
\description{
Run all active unit tests defined on a stock-and-flow model. Use
\code{\link[=unit_test]{unit_test()}} to define tests; use \code{\link[=unit_tests]{unit_tests()}} to display them.
}
\details{
Calling \code{verify()} on a \code{stockflow} model will first simulate the model, then
run all tests — including those that require re-simulation under alternative
\link[=unit_test]{conditions}. Simulations are always retained in the returned
object so that \code{\link[=plot.verify_stockflow]{plot.verify_stockflow()}} works without any extra arguments.

For repeated-run robustness testing use \code{\link[=ensemble]{ensemble()}} instead.
}
\examples{
sfm <- stockflow("sir") |>
  unit_test(expr = all(susceptible >= 0)) |>
  unit_test(
    label = "recovered increases over time",
    expr = all(diff(recovered) >= 0)
  )

verify(sfm)
}
\seealso{
\code{\link[=unit_test]{unit_test()}}, \code{\link[=unit_tests]{unit_tests()}}, \code{\link[=simulate.stockflow]{simulate.stockflow()}},
\code{\link[=as.data.frame.verify_stockflow]{as.data.frame.verify_stockflow()}}, \code{\link[=plot.verify_stockflow]{plot.verify_stockflow()}}
}
\concept{unitTest}
