nim-unittest2/unittest2.html

939 lines
86 KiB
HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>unittest2</title>
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
<script type="text/javascript" src="dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
toggleSwitch.addEventListener('change', switchTheme, false);
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-theme', "dark");
toggleSwitch.checked = true;
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
document.documentElement.setAttribute('data-theme', "light");
toggleSwitch.checked = false;
} else {
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
}
}
</script>
</head>
<body onload="main()">
<div class="document" id="documentId">
<div class="container">
<h1 class="title">unittest2</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li><a class="reference" id="running-individual-tests_toc" href="#running-individual-tests">Running individual tests</a></li>
<li><a class="reference" id="running-a-single-test-suite_toc" href="#running-a-single-test-suite">Running a single test suite</a></li>
<li><a class="reference" id="selecting-tests-by-pattern_toc" href="#selecting-tests-by-pattern">Selecting tests by pattern</a></li>
<li><a class="reference" id="command-line-arguments_toc" href="#command-line-arguments">Command line arguments</a></li>
<li><a class="reference" id="running-tests-in-parallel_toc" href="#running-tests-in-parallel">Running tests in parallel</a></li>
<ul class="simple"><li><a class="reference" id="running-tests-in-parallel-example_toc" href="#running-tests-in-parallel-example">Example</a></li>
</ul><li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#TestStatus"
title="TestStatus = enum
OK, FAILED, SKIPPED"><wbr />Test<wbr />Status<span class="attachedType"></span></a></li>
<li><a class="reference" href="#OutputLevel"
title="OutputLevel = enum
PRINT_ALL, ## Print as much as possible.
PRINT_FAILURES, ## Print only the failed tests.
PRINT_NONE ## Print nothing."><wbr />Output<wbr />Level<span class="attachedType"></span></a></li>
<li><a class="reference" href="#TestResult"
title="TestResult = object
suiteName*: string ## Name of the test suite that contains this test case.
## Can be ``nil`` if the test case is not in a suite.
testName*: string ## Name of the test case
status*: TestStatus
duration*: Duration"><wbr />Test<wbr />Result<span class="attachedType"></span></a></li>
<li><a class="reference" href="#OutputFormatter"
title="OutputFormatter = ref object of RootObj"><wbr />Output<wbr />Formatter<span class="attachedType"></span></a></li>
<li><a class="reference" href="#ConsoleOutputFormatter"
title="ConsoleOutputFormatter = ref object of OutputFormatter
colorOutput: bool ## Have test results printed in color.
## Default is `auto` depending on `isatty(stdout)`, or override it with
## `-d:nimUnittestColor:auto|on|off`.
##
## Deprecated: Setting the environment variable `NIMTEST_COLOR` to `always`
## or `never` changes the default for the non-js target to true or false respectively.
## Deprecated: the environment variable `NIMTEST_NO_COLOR`, when set, changes the
## default to true, if `NIMTEST_COLOR` is undefined.
outputLevel: OutputLevel ## Set the verbosity of test results.
## Default is `PRINT_ALL`, or override with:
## `-d:nimUnittestOutputLevel:PRINT_ALL|PRINT_FAILURES|PRINT_NONE`.
##
## Deprecated: the `NIMTEST_OUTPUT_LVL` environment variable is set for the non-js target.
isInSuite: bool
isInTest: bool"><wbr />Console<wbr />Output<wbr />Formatter<span class="attachedType"></span></a></li>
<li><a class="reference" href="#JUnitOutputFormatter"
title="JUnitOutputFormatter = ref object of OutputFormatter
stream: Stream
defaultSuite: JUnitSuite
suites: seq[JUnitSuite]
currentSuite: int"><wbr />JUnit<wbr />Output<wbr />Formatter<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#8" id="58">Vars</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#abortOnError"
title="abortOnError: bool"><wbr />abort<wbr />On<wbr />Error<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#paralleliseTests"
title="paralleliseTests = false"><wbr />parallelise<wbr />Tests<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#addOutputFormatter%2COutputFormatter"
title="addOutputFormatter(formatter: OutputFormatter)"><wbr />add<wbr />Output<wbr />Formatter<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#resetOutputFormatters"
title="resetOutputFormatters()"><wbr />reset<wbr />Output<wbr />Formatters<span class="attachedType"></span></a></li>
<li><a class="reference" href="#newConsoleOutputFormatter%2COutputLevel"
title="newConsoleOutputFormatter(outputLevel: OutputLevel = outputLevelDefault;
colorOutput = true): ConsoleOutputFormatter"><wbr />new<wbr />Console<wbr />Output<wbr />Formatter<span class="attachedType">OutputLevel</span></a></li>
<li><a class="reference" href="#defaultConsoleFormatter"
title="defaultConsoleFormatter(): ConsoleOutputFormatter"><wbr />default<wbr />Console<wbr />Formatter<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#newJUnitOutputFormatter%2CStream"
title="newJUnitOutputFormatter(stream: Stream): JUnitOutputFormatter"><wbr />new<wbr />JUnit<wbr />Output<wbr />Formatter<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#parseParameters%2CopenArray%5Bstring%5D"
title="parseParameters(args: openArray[string])"><wbr />parse<wbr />Parameters<span class="attachedType"></span></a></li>
<li><a class="reference" href="#checkpoint%2Cstring"
title="checkpoint(msg: string)"><wbr />checkpoint<span class="attachedType"></span></a></li>
<li><a class="reference" href="#disableParamFiltering"
title="disableParamFiltering()"><wbr />disable<wbr />Param<wbr />Filtering<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#14" id="64">Methods</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#suiteStarted.e%2COutputFormatter%2Cstring"
title="suiteStarted(formatter: OutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2COutputFormatter%2Cstring"
title="testStarted(formatter: OutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2COutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: OutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2COutputFormatter%2CTestResult"
title="testEnded(formatter: OutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2COutputFormatter"
title="suiteEnded(formatter: OutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#testRunEnded.e%2COutputFormatter"
title="testRunEnded(formatter: OutputFormatter)"><wbr />test<wbr />Run<wbr />Ended<span class="attachedType">OutputFormatter</span></a></li>
<li><a class="reference" href="#suiteStarted.e%2CConsoleOutputFormatter%2Cstring"
title="suiteStarted(formatter: ConsoleOutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2CConsoleOutputFormatter%2Cstring"
title="testStarted(formatter: ConsoleOutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2CConsoleOutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: ConsoleOutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2CConsoleOutputFormatter%2CTestResult"
title="testEnded(formatter: ConsoleOutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2CConsoleOutputFormatter"
title="suiteEnded(formatter: ConsoleOutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteStarted.e%2CJUnitOutputFormatter%2Cstring"
title="suiteStarted(formatter: JUnitOutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2CJUnitOutputFormatter%2Cstring"
title="testStarted(formatter: JUnitOutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2CJUnitOutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: JUnitOutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2CJUnitOutputFormatter%2CTestResult"
title="testEnded(formatter: JUnitOutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2CJUnitOutputFormatter"
title="suiteEnded(formatter: JUnitOutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#testRunEnded.e%2CJUnitOutputFormatter"
title="testRunEnded(formatter: JUnitOutputFormatter)"><wbr />test<wbr />Run<wbr />Ended<span class="attachedType">JUnitOutputFormatter</span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#17" id="67">Macros</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#check.m%2Cuntyped"
title="check(conditions: untyped): untyped"><wbr />check<span class="attachedType"></span></a></li>
<li><a class="reference" href="#expect.m%2Cvarargs%5Btyped%5D%2Cuntyped"
title="expect(exceptions: varargs[typed]; body: untyped): untyped"><wbr />expect<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#suite.t%2C%2C"
title="suite(name, body)"><wbr />suite<span class="attachedType"></span></a></li>
<li><a class="reference" href="#test.t%2Cstring%2Cuntyped"
title="test(name: string; body: untyped)"><wbr />test<span class="attachedType"></span></a></li>
<li><a class="reference" href="#fail.t"
title="fail()"><wbr />fail<span class="attachedType"></span></a></li>
<li><a class="reference" href="#skip.t"
title="skip()"><wbr />skip<span class="attachedType"></span></a></li>
<li><a class="reference" href="#require.t%2Cuntyped"
title="require(conditions: untyped)"><wbr />require<span class="attachedType"></span></a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"><table class="docinfo" frame="void" rules="none"><col class="docinfo-name" /><col class="docinfo-content" /><tbody valign="top"><tr><th class="docinfo-name">Authors:</th><td> Zahary Karadjov, Ștefan Talpalaru</td></tr>
</tbody></table><p>This module implements boilerplate to make unit testing easy.</p>
<p>The test status and name is printed after any output or traceback.</p>
<p>Tests can be nested, however failure of a nested test will not mark the parent test as failed. Setup and teardown are inherited. Setup can be overridden locally.</p>
<p>Compiled test files return the number of failed test as exit code, while</p>
<pre class="listing">nim c -r testfile.nim</pre><p>exits with 0 or 1.</p>
<h1><a class="toc-backref" id="running-individual-tests" href="#running-individual-tests">Running individual tests</a></h1><p>Specify the test names as command line arguments.</p>
<pre class="listing">
nim c -r test &quot;my test name&quot; &quot;another test&quot;</pre><p>Multiple arguments can be used.</p>
<h1><a class="toc-backref" id="running-a-single-test-suite" href="#running-a-single-test-suite">Running a single test suite</a></h1><p>Specify the suite name delimited by <tt class="docutils literal"><span class="pre">&quot;::&quot;</span></tt>.</p>
<pre class="listing">
nim c -r test &quot;my suite name::&quot;</pre>
<h1><a class="toc-backref" id="selecting-tests-by-pattern" href="#selecting-tests-by-pattern">Selecting tests by pattern</a></h1><p>A single <tt class="docutils literal"><span class="pre">&quot;*&quot;</span></tt> can be used for globbing.</p>
<p>Delimit the end of a suite name with <tt class="docutils literal"><span class="pre">&quot;::&quot;</span></tt>.</p>
<p>Tests matching <strong>any</strong> of the arguments are executed.</p>
<pre class="listing">
nim c -r test fast_suite::mytest1 fast_suite::mytest2
nim c -r test &quot;fast_suite::mytest*&quot;
nim c -r test &quot;auth*::&quot; &quot;crypto::hashing*&quot;
# Run suites starting with 'bug #' and standalone tests starting with '#'
nim c -r test 'bug #*::' '::#*'</pre>
<h1><a class="toc-backref" id="command-line-arguments" href="#command-line-arguments">Command line arguments</a></h1><table frame="void"><tr><th align="left">--help</th><td align="left">Print short help and quit</td>
</tr>
<tr><th align="left">--xml:file</th><td align="left">Write JUnit-compatible XML report to <tt class="docutils literal"><span class="pre">file</span></tt></td>
</tr>
<tr><th align="left">--console</th><td align="left">Write report to the console (default, when no other output is selected)</td>
</tr>
</table><p>Command line parsing can be disabled with <tt class="docutils literal"><span class="pre">-d:unittest2DisableParamFiltering</span></tt>.</p>
<h1><a class="toc-backref" id="running-tests-in-parallel" href="#running-tests-in-parallel">Running tests in parallel</a></h1><p>To enable the threadpool-based test parallelisation, &quot;--threads:on&quot; needs to be passed to the compiler, along with &quot;-d:nimtestParallel&quot; or the NIMTEST_PARALLEL environment variable:</p>
<pre class="listing">
nim c -r --threads:on -d:nimtestParallel testfile.nim
# or
NIMTEST_PARALLEL=1 nim c -r --threads:on testfile.nim</pre><p>There are some implicit barriers where we wait for all the spawned jobs to complete: before and after each test suite and at the main thread's exit.</p>
<p>The suite-related barriers are there to avoid mixing test output, but they also affect which groups of tests can be run in parallel, so keep them in mind when deciding how many tests to place in different suites (or between suites).</p>
<p>You may sometimes need to disable test parallelisation for a specific test, even though it was enabled in some configuration file in a parent dir. Do this with &quot;-d:nimtestParallelDisabled&quot; which overrides everything else.</p>
<h2><a class="toc-backref" id="running-tests-in-parallel-example" href="#running-tests-in-parallel-example">Example</a></h2><pre class="listing"><span class="Identifier">suite</span> <span class="StringLit">&quot;description for this stuff&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;suite setup: run once before the tests&quot;</span>
<span class="Identifier">setup</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;run before each test&quot;</span>
<span class="Identifier">teardown</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;run after each test&quot;</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;essential truths&quot;</span><span class="Punctuation">:</span>
<span class="Comment"># give up and stop if this fails</span>
<span class="Identifier">require</span><span class="Punctuation">(</span><span class="Identifier">true</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;slightly less obvious stuff&quot;</span><span class="Punctuation">:</span>
<span class="Comment"># print a nasty message and move on, skipping</span>
<span class="Comment"># the remainder of this block</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">!=</span> <span class="DecNumber">1</span><span class="Punctuation">)</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="StringLit">&quot;asd&quot;</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'d'</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;out of bounds error is thrown on bad access&quot;</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span> <span class="Comment"># you can do initialization here</span>
<span class="Identifier">expect</span><span class="Punctuation">(</span><span class="Identifier">IndexError</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
<span class="Keyword">discard</span> <span class="Identifier">v</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">]</span>
<span class="Identifier">suiteTeardown</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;suite teardown: run once after the tests&quot;</span></pre></p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<a id="TestStatus"></a>
<dt><pre><a href="unittest2.html#TestStatus"><span class="Identifier">TestStatus</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">OK</span><span class="Other">,</span> <span class="Identifier">FAILED</span><span class="Other">,</span> <span class="Identifier">SKIPPED</span></pre></dt>
<dd>
The status of a test when it is done.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L186"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L186" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="OutputLevel"></a>
<dt><pre><a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">PRINT_ALL</span><span class="Other">,</span> <span class="Comment">## Print as much as possible.</span>
<span class="Identifier">PRINT_FAILURES</span><span class="Other">,</span> <span class="Comment">## Print only the failed tests.</span>
<span class="Identifier">PRINT_NONE</span> <span class="Comment">## Print nothing.</span></pre></dt>
<dd>
The output verbosity of the tests.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L191"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L191" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="TestResult"></a>
<dt><pre><a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">suiteName</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Comment">## Name of the test suite that contains this test case.</span>
<span class="Comment">## Can be ``nil`` if the test case is not in a suite.</span>
<span class="Identifier">testName</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Comment">## Name of the test case</span>
<span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <a href="unittest2.html#TestStatus"><span class="Identifier">TestStatus</span></a>
<span class="Identifier">duration</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Duration</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L196"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L196" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="OutputFormatter"></a>
<dt><pre><a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">RootObj</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L205"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L205" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="ConsoleOutputFormatter"></a>
<dt><pre><a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a>
<span class="Identifier">colorOutput</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## Have test results printed in color.</span>
<span class="Comment">## Default is `auto` depending on `isatty(stdout)`, or override it with</span>
<span class="Comment">## `-d:nimUnittestColor:auto|on|off`.</span>
<span class="Comment">## </span>
<span class="Comment">## Deprecated: Setting the environment variable `NIMTEST_COLOR` to `always`</span>
<span class="Comment">## or `never` changes the default for the non-js target to true or false respectively.</span>
<span class="Comment">## Deprecated: the environment variable `NIMTEST_NO_COLOR`, when set, changes the</span>
<span class="Comment">## default to true, if `NIMTEST_COLOR` is undefined.</span>
<span class="Identifier">outputLevel</span><span class="Other">:</span> <a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Comment">## Set the verbosity of test results.</span>
<span class="Comment">## Default is `PRINT_ALL`, or override with:</span>
<span class="Comment">## `-d:nimUnittestOutputLevel:PRINT_ALL|PRINT_FAILURES|PRINT_NONE`.</span>
<span class="Comment">## </span>
<span class="Comment">## Deprecated: the `NIMTEST_OUTPUT_LVL` environment variable is set for the non-js target.</span>
<span class="Identifier">isInSuite</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">isInTest</span><span class="Other">:</span> <span class="Identifier">bool</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L207"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L207" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="JUnitOutputFormatter"></a>
<dt><pre><a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a>
<span class="Identifier">stream</span><span class="Other">:</span> <span class="Identifier">Stream</span>
<span class="Identifier">defaultSuite</span><span class="Other">:</span> <span class="Identifier">JUnitSuite</span>
<span class="Identifier">suites</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">JUnitSuite</span><span class="Other">]</span>
<span class="Identifier">currentSuite</span><span class="Other">:</span> <span class="Identifier">int</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L236"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L236" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<a id="abortOnError"></a>
<dt><pre><a href="unittest2.html#abortOnError"><span class="Identifier">abortOnError</span></a><span class="Other">:</span> <span class="Identifier">bool</span></pre></dt>
<dd>
<p>Set to true in order to quit immediately on fail. Default is false, or override with <tt class="docutils literal"><span class="pre">-d:nimUnittestAbortOnError:on|off</span></tt>.</p>
<p>Deprecated: can also override depending on whether <tt class="docutils literal"><span class="pre">NIMTEST_ABORT_ON_ERROR</span></tt> environment variable is set.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L243"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L243" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<a id="paralleliseTests"></a>
<dt><pre><a href="unittest2.html#paralleliseTests"><span class="Identifier">paralleliseTests</span></a> <span class="Other">=</span> <span class="DecNumber">false</span></pre></dt>
<dd>
Whether parallel test running was enabled (set at compile time). This constant might be useful in custom output formatters.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L148"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L148" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<a id="addOutputFormatter,OutputFormatter"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#addOutputFormatter%2COutputFormatter"><span class="Identifier">addOutputFormatter</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L294"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L294" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="resetOutputFormatters"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#resetOutputFormatters"><span class="Identifier">resetOutputFormatters</span></a><span class="Other">(</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L299"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L299" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="newConsoleOutputFormatter,OutputLevel"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#newConsoleOutputFormatter%2COutputLevel"><span class="Identifier">newConsoleOutputFormatter</span></a><span class="Other">(</span><span class="Identifier">outputLevel</span><span class="Other">:</span> <a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Other">=</span> <span class="Identifier">outputLevelDefault</span><span class="Other">;</span>
<span class="Identifier">colorOutput</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L304"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L304" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="defaultConsoleFormatter"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#defaultConsoleFormatter"><span class="Identifier">defaultConsoleFormatter</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L331"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L331" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="newJUnitOutputFormatter,Stream"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#newJUnitOutputFormatter%2CStream"><span class="Identifier">newJUnitOutputFormatter</span></a><span class="Other">(</span><span class="Identifier">stream</span><span class="Other">:</span> <span class="Identifier">Stream</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Creates a formatter that writes report to the specified stream in JUnit format. The <tt class="docutils literal"><span class="pre">stream</span></tt> is NOT closed automatically when the test are finished, because the formatter has no way to know when all tests are finished. You should invoke formatter.close() to finalize the report.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L408"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L408" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="parseParameters,openArray[string]"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#parseParameters%2CopenArray%5Bstring%5D"><span class="Identifier">parseParameters</span></a><span class="Other">(</span><span class="Identifier">args</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L582"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L582" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="checkpoint,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#checkpoint%2Cstring"><span class="Identifier">checkpoint</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Set a checkpoint identified by <tt class="docutils literal"><span class="pre">msg</span></tt>. Upon test failure all checkpoints encountered so far are printed out. Example:<pre class="listing"><span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint A&quot;</span><span class="Punctuation">)</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">&quot;the Answer to life and everything&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
<span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint B&quot;</span><span class="Punctuation">)</span></pre><p>outputs &quot;Checkpoint A&quot; once it fails.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L777"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L777" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="disableParamFiltering"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#disableParamFiltering"><span class="Identifier">disableParamFiltering</span></a><span class="Other">(</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Compile with -d:unittest2DisableParamFiltering instead&quot;</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<div class="deprecation-message">
<b>Deprecated:</b> Compile with -d:unittest2DisableParamFiltering instead
</div>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L978"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L978" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="14">
<h1><a class="toc-backref" href="#14">Methods</a></h1>
<dl class="item">
<a id="suiteStarted.e,OutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteStarted.e%2COutputFormatter%2Cstring"><span class="Identifier">suiteStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span>
<span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L275"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L275" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testStarted.e,OutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testStarted.e%2COutputFormatter%2Cstring"><span class="Identifier">testStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L277"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L277" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="failureOccurred.e,OutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#failureOccurred.e%2COutputFormatter%2Cseq%5Bstring%5D%2Cstring"><span class="Identifier">failureOccurred</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<tt class="docutils literal"><span class="pre">stackTrace</span></tt> is provided only if the failure occurred due to an exception. <tt class="docutils literal"><span class="pre">checkpoints</span></tt> is never <tt class="docutils literal"><span class="pre">nil</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L279"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L279" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testEnded.e,OutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testEnded.e%2COutputFormatter%2CTestResult"><span class="Identifier">testEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span>
<span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L284"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L284" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="suiteEnded.e,OutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteEnded.e%2COutputFormatter"><span class="Identifier">suiteEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L286"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L286" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testRunEnded.e,OutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testRunEnded.e%2COutputFormatter"><span class="Identifier">testRunEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L288"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L288" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="suiteStarted.e,ConsoleOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteStarted.e%2CConsoleOutputFormatter%2Cstring"><span class="Identifier">suiteStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L345"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L345" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testStarted.e,ConsoleOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testStarted.e%2CConsoleOutputFormatter%2Cstring"><span class="Identifier">testStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L356"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L356" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="failureOccurred.e,ConsoleOutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#failureOccurred.e%2CConsoleOutputFormatter%2Cseq%5Bstring%5D%2Cstring"><span class="Identifier">failureOccurred</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span>
<span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L359"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L359" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testEnded.e,ConsoleOutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testEnded.e%2CConsoleOutputFormatter%2CTestResult"><span class="Identifier">testEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L367"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L367" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="suiteEnded.e,ConsoleOutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteEnded.e%2CConsoleOutputFormatter"><span class="Identifier">suiteEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L390"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L390" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="suiteStarted.e,JUnitOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteStarted.e%2CJUnitOutputFormatter%2Cstring"><span class="Identifier">suiteStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L431"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L431" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testStarted.e,JUnitOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testStarted.e%2CJUnitOutputFormatter%2Cstring"><span class="Identifier">testStarted</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L435"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L435" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="failureOccurred.e,JUnitOutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <a href="#failureOccurred.e%2CJUnitOutputFormatter%2Cseq%5Bstring%5D%2Cstring"><span class="Identifier">failureOccurred</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span>
<span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<tt class="docutils literal"><span class="pre">stackTrace</span></tt> is provided only if the failure occurred due to an exception. <tt class="docutils literal"><span class="pre">checkpoints</span></tt> is never <tt class="docutils literal"><span class="pre">nil</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L438"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L438" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testEnded.e,JUnitOutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testEnded.e%2CJUnitOutputFormatter%2CTestResult"><span class="Identifier">testEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L447"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L447" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="suiteEnded.e,JUnitOutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <a href="#suiteEnded.e%2CJUnitOutputFormatter"><span class="Identifier">suiteEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L450"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L450" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="testRunEnded.e,JUnitOutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <a href="#testRunEnded.e%2CJUnitOutputFormatter"><span class="Identifier">testRunEnded</span></a><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Defect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Completes the report and closes the underlying stream.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L508"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L508" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="17">
<h1><a class="toc-backref" href="#17">Macros</a></h1>
<dl class="item">
<a id="check.m,untyped"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#check.m%2Cuntyped"><span class="Identifier">check</span></a><span class="Other">(</span><span class="Identifier">conditions</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Verify if a statement or a list of statements is true. A helpful error message and set checkpoints are printed out on failure (if <tt class="docutils literal"><span class="pre">outputLevel</span></tt> is not <tt class="docutils literal"><span class="pre">PRINT_NONE</span></tt>).
<p><strong class="examples_text">Examples:</strong></p>
<pre class="listing"><span class="Keyword">import</span>
<span class="Identifier">std</span> <span class="Operator">/</span> <span class="Identifier">strutils</span>
<span class="Identifier">check</span><span class="Other">(</span><span class="StringLit">&quot;AKB48&quot;</span><span class="Other">.</span><span class="Identifier">toLowerAscii</span><span class="Other">(</span><span class="Other">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;akb48&quot;</span><span class="Other">)</span>
<span class="Keyword">let</span> <span class="Identifier">teams</span> <span class="Other">=</span> <span class="Other">{</span><span class="CharLit">'A'</span><span class="Other">,</span> <span class="CharLit">'K'</span><span class="Other">,</span> <span class="CharLit">'B'</span><span class="Other">,</span> <span class="CharLit">'4'</span><span class="Other">,</span> <span class="CharLit">'8'</span><span class="Other">}</span>
<span class="Identifier">check</span><span class="Other">:</span>
<span class="StringLit">&quot;AKB48&quot;</span><span class="Other">.</span><span class="Identifier">toLowerAscii</span><span class="Other">(</span><span class="Other">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;akb48&quot;</span>
<span class="CharLit">'C'</span> <span class="Keyword">notin</span> <span class="Identifier">teams</span></pre>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L839"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L839" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="expect.m,varargs[typed],untyped"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#expect.m%2Cvarargs%5Btyped%5D%2Cuntyped"><span class="Identifier">expect</span></a><span class="Other">(</span><span class="Identifier">exceptions</span><span class="Other">:</span> <span class="Identifier">varargs</span><span class="Other">[</span><span class="Identifier">typed</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">body</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Test if <tt class="docutils literal"><span class="pre">body</span></tt> raises an exception found in the passed <tt class="docutils literal"><span class="pre">exceptions</span></tt>. The test passes if the raised exception is part of the acceptable exceptions. Otherwise, it fails.
<p><strong class="examples_text">Examples:</strong></p>
<pre class="listing"><span class="Keyword">import</span>
<span class="Identifier">std</span> <span class="Operator">/</span> <span class="Other">[</span><span class="Identifier">math</span><span class="Other">,</span> <span class="Identifier">random</span><span class="Other">,</span> <span class="Identifier">strutils</span><span class="Other">]</span>
<span class="Keyword">proc</span> <span class="Identifier">defectiveRobot</span><span class="Other">(</span><span class="Other">)</span> <span class="Other">=</span>
<span class="Identifier">randomize</span><span class="Other">(</span><span class="Other">)</span>
<span class="Keyword">case</span> <span class="Identifier">rand</span><span class="Other">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Other">)</span>
<span class="Keyword">of</span> <span class="DecNumber">1</span><span class="Other">:</span>
<span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Other">(</span><span class="Identifier">OSError</span><span class="Other">,</span> <span class="StringLit">&quot;CANNOT COMPUTE!&quot;</span><span class="Other">)</span>
<span class="Keyword">of</span> <span class="DecNumber">2</span><span class="Other">:</span>
<span class="Keyword">discard</span> <span class="Identifier">parseInt</span><span class="Other">(</span><span class="StringLit">&quot;Hello World!&quot;</span><span class="Other">)</span>
<span class="Keyword">of</span> <span class="DecNumber">3</span><span class="Other">:</span>
<span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Other">(</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="StringLit">&quot;I can\'t do that Dave.&quot;</span><span class="Other">)</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Identifier">assert</span> <span class="DecNumber">2</span> <span class="Operator">+</span> <span class="DecNumber">2</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
<span class="Keyword">when</span> <span class="Other">(</span><span class="Identifier">NimMajor</span><span class="Other">,</span> <span class="Identifier">NimMinor</span><span class="Other">,</span> <span class="Identifier">NimPatch</span><span class="Other">)</span> <span class="Operator">&lt;</span> <span class="Other">(</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="DecNumber">4</span><span class="Other">,</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span>
<span class="Keyword">type</span>
<span class="Identifier">AssertionDefect</span> <span class="Other">=</span> <span class="Identifier">AssertionError</span>
<span class="Identifier">expect</span> <span class="Identifier">IOError</span><span class="Other">,</span><span class="Identifier">OSError</span><span class="Other">,</span><span class="Identifier">ValueError</span><span class="Other">,</span><span class="Identifier">AssertionDefect</span><span class="Other">:</span>
<span class="Identifier">defectiveRobot</span><span class="Other">(</span><span class="Other">)</span></pre>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L941"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L941" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<a id="suite.t,,"></a>
<dt><pre><span class="Keyword">template</span> <a href="#suite.t%2C%2C"><span class="Identifier">suite</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">body</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">dirty</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Declare a test suite identified by <tt class="docutils literal"><span class="pre">name</span></tt> with optional <tt class="docutils literal"><span class="pre">setup</span></tt> and/or <tt class="docutils literal"><span class="pre">teardown</span></tt> section.</p>
<p>A test suite is a series of one or more related tests sharing a common fixture (<tt class="docutils literal"><span class="pre">setup</span></tt>, <tt class="docutils literal"><span class="pre">teardown</span></tt>). The fixture is executed for EACH test.</p>
<pre class="listing"><span class="Identifier">suite</span> <span class="StringLit">&quot;test suite for addition&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">setup</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="DecNumber">4</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;2 + 2 = 4&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Operator">+</span><span class="DecNumber">2</span> <span class="Operator">==</span> <span class="Identifier">result</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;(2 + -2) != 4&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">+</span> <span class="Operator">-</span><span class="DecNumber">2</span> <span class="Operator">!=</span> <span class="Identifier">result</span><span class="Punctuation">)</span>
<span class="Comment"># No teardown needed</span></pre><p>The suite will run the individual test cases in the order in which they were listed. With default global settings the above code prints:</p>
<pre class="listing"><span class="Punctuation">[</span><span class="Identifier">Suite</span><span class="Punctuation">]</span> <span class="Identifier">test</span> <span class="Identifier">suite</span> <span class="Keyword">for</span> <span class="Identifier">addition</span>
<span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="DecNumber">2</span> <span class="Operator">+</span> <span class="DecNumber">2</span> <span class="Operator">=</span> <span class="DecNumber">4</span>
<span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">+</span> <span class="Operator">-</span><span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">!=</span> <span class="DecNumber">4</span></pre>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L650"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L650" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="test.t,string,untyped"></a>
<dt><pre><span class="Keyword">template</span> <a href="#test.t%2Cstring%2Cuntyped"><span class="Identifier">test</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">body</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span></pre></dt>
<dd>
Define a single test case identified by <tt class="docutils literal"><span class="pre">name</span></tt>.<pre class="listing"><span class="Identifier">test</span> <span class="StringLit">&quot;roses are red&quot;</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">roses</span> <span class="Operator">=</span> <span class="StringLit">&quot;red&quot;</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="Identifier">roses</span> <span class="Operator">==</span> <span class="StringLit">&quot;red&quot;</span><span class="Punctuation">)</span></pre><p>The above code outputs:</p>
<pre class="listing"><span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="Identifier">roses</span> <span class="Identifier">are</span> <span class="Identifier">red</span></pre>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L708"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L708" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="fail.t"></a>
<dt><pre><span class="Keyword">template</span> <a href="#fail.t"><span class="Identifier">fail</span></a><span class="Other">(</span><span class="Other">)</span></pre></dt>
<dd>
Print out the checkpoints encountered so far and quit if <tt class="docutils literal"><span class="pre">abortOnError</span></tt> is true. Otherwise, erase the checkpoints and indicate the test has failed (change exit code and test status). This template is useful for debugging, but is otherwise mostly used internally. Example:<pre class="listing"><span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint A&quot;</span><span class="Punctuation">)</span>
<span class="Identifier">complicatedProcInThread</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
<span class="Identifier">fail</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre><p>outputs &quot;Checkpoint A&quot; before quitting.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L791"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L791" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="skip.t"></a>
<dt><pre><span class="Keyword">template</span> <a href="#skip.t"><span class="Identifier">skip</span></a><span class="Other">(</span><span class="Other">)</span></pre></dt>
<dd>
Mark the test as skipped. Should be used directly in case when it is not possible to perform test for reasons depending on outer environment, or certain application logic conditions or configurations. The test code is still executed.<pre class="listing"><span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Identifier">isGLContextCreated</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
<span class="Identifier">skip</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L821"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L821" class="link-seesrc" target="_blank" >Edit</a>
</dd>
<a id="require.t,untyped"></a>
<dt><pre><span class="Keyword">template</span> <a href="#require.t%2Cuntyped"><span class="Identifier">require</span></a><span class="Other">(</span><span class="Identifier">conditions</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span></pre></dt>
<dd>
Same as <tt class="docutils literal"><span class="pre">check</span></tt> except any failed test causes the program to quit immediately. Any teardown statements are not executed and the failed test output is not generated.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-unittest2/tree/master/unittest2.nim#L931"
class="link-seesrc" target="_blank">Source</a>
<a href="https://github.com/status-im/nim-unittest2/edit/master/unittest2.nim#L931" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-04-28 17:08:39 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>