% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run_covr_skip_nstf.R
\name{create_tinytest_coverage}
\alias{create_tinytest_coverage}
\title{Create coverage from tinytest under covr instrumentation (internal)}
\usage{
create_tinytest_coverage(
  pkg_source_path,
  pkg_name,
  tiny_dir = file.path(pkg_source_path, "inst", "tinytest"),
  at_home = TRUE,
  color = FALSE
)
}
\arguments{
\item{pkg_source_path}{Character scalar. Path to the package source root.}

\item{pkg_name}{Character scalar. Package name (as in \code{DESCRIPTION}).}

\item{tiny_dir}{Optional override for the tinytest directory. Defaults
to \code{file.path(pkg_source_path, "inst", "tinytest")}.}

\item{at_home}{Logical; passed to \code{tinytest::run_test_dir()}.
Defaults to \code{TRUE}.}

\item{color}{Logical; color output from tinytest. Defaults to \code{FALSE}.}
}
\value{
A list with components:
\describe{
  \item{coverage}{An object of class \code{"coverage"} (from \pkg{covr}).}
  \item{tinytests}{The \code{tinytests} object returned by tinytest.}
}
}
\description{
Instruments the package **namespace** with \pkg{covr}, runs all
\pkg{tinytest} files in \code{inst/tinytest}, and returns a covr coverage
object together with the tinytest results. This mirrors tinytest's execution
model (expectation helpers available; tests run from each file's directory)
while ensuring calls into the package namespace are traced.
}
\details{
Intended for **source-tree** coverage of tinytest suites:
\itemize{
  \item The package namespace is traced via \code{covr::trace_environment()}
        so that calls made by tests to package functions are recorded
        for coverage.
  \item \code{NOT_CRAN} is set to \code{"true"} during the run (restored on exit)
        so tinytest \code{at_home()} logic treats the run as local.
  \item Test files are driven by \code{tinytest::run_test_dir()} from
        \code{file.path(pkg_source_path, "inst", "tinytest")}.
  \item Coverage is built from covr's counters using \code{covr::as_coverage()}.
}

\strong{Preconditions}
\itemize{
  \item The package under test should already be \emph{loaded} (e.g.,
        \code{pkgload::load_all(pkg_source_path)}), so that
        \code{asNamespace(pkg_name)} exists and reflects the current source.
  \item The directory \code{inst/tinytest} must exist and contain test files.
}
}
\seealso{
Other nstf_utility: 
\code{\link{check_covr_skip_testit}()},
\code{\link{create_base_tests_coverage}()},
\code{\link{create_nstf_covr_list}()},
\code{\link{get_nstf_test_path}()},
\code{\link{get_source_test_mapping_nstf}()},
\code{\link{restrict_test_paths_to_framework}()},
\code{\link{run_covr_skip_nstf}()}
}
\concept{nstf_utility}
\keyword{internal}
