PacletAssurance`
PacletAssurance`

TestFile

TestFile[symbol]

searches for a test file associated with symbol.

TestFile["symbol"]

searches for a test file associated with the symbol named "symbol".

TestFile["symbol/name"]

searches for a test file associated with the location "symbol/name".

TestFile[{PacletObject[],,"name"}]

searches for a test file with path ending in name and starting with a root specified by the paclet object.

Details and Options

  • TestFile returns a full absolute filename.
  • TestSummary and TestReport are typically applied to the file returned by TestFile.
  • TestFile["symbol"] is equivalent to TestFile[{PacletObject[], "symbol"}] where the paclet specifies the symbol's context and the root of the returned filename.
  • TestFile["symbol/name"] is equivalent to TestFile[{PacletObject[], "symbol/name"}] where the paclet specifies the symbol's context and root of the returned filename.
  • In TestFile[{PacletObject[], }] the implicit root associated with the paclet object is, by default, a TestFiles directory defined in PacletInfo.wl which itself necessarily includes, in its Extensions key, the entry {"TestFiles","Root""TestFiles"} .
  • In TestFile[symbol] and TestFile["symbol"] by default, test files are searched for in the following order: root/symbol.wlt, root/symbol/core.wlt, root/symbol/core.wlt, root/symbol.nb, root/symbol/core.nb.
  • Explicit file extensions in TestFile["symbol.ext"], TestFile["symbol/name.ext"], TestFile[,".../name.ext"] are supported where .ext is either .wlt or .nb.
  • When no file extension is specified the type of test files that are searched for and in what order is determined by the "TestFileExtension" option.
  • TestFile["symbol/ /name"] is equivalent to TestFile[{"symbol", , "name"}].
  • TestFile[{object, , "name"}] is equivalent to TestFile[{object,".../name"}].
  • If TestFile[,".../name"] resolves to a folder, the filename TestFile[,".../name/name.ext"] is searched for with .ext given by the "TestFileExtension" option.
  • The list of all implicit TestFiles directories defined by all paclets is returned by PacletManager`PacletResources["TestFiles"]
  • TestFile returns $Failed if it cannot find a file with the specified name and location.
  • The following options can be given:
  • "TestFileExtensionAutomaticspecifies the test file extension to search for
  • Possible settings for "TestFileExtension" include:
  • ".wlt"search only for a test file with extension .wlt
    ".nb"search only for a test file with extension .nb
    {".wlt",".nb"}search first for a test file with extension .wlt and failing this search for one with extension .nb
    {".nb",".wlt"}search first for a test file with extension .nb and failing this search for one with extension .wlt
    Automaticequivalent to the setting {".wlt", ".nb"}

Examples

Basic Examples  (1)

Find the file containing the core unit tests for the TestFile function.

Find a test file that contains exception handling unit tests for TestFile.

compare test summaries for each

obtain a summary for the combination of these summaries.

Creating summaries and reports from a .wlt file created from its corresponding .nb file is faster since the test extraction from a notebook has effectively already been performed.

Tech Notes
  • Testing that Scales
  • Paclet Workflow
  • Using the Testing Framework