This function queries an LLM to write unit tests for selected R code. To do so, it:

  • Initializes a ensurer(): an ellmer Chat() that knows how to write testthat unit tests.

  • Reads the contents of the active .R file as well as the current selection.

  • Opens a corresponding test file (creating it if need be).

  • Asks the LLM to write unit tests for the current selection, using the contents of the active .R file as context.

  • Streams the response into the corresponding test file.

ensure_that()

Value

TRUE, invisibly.