Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 5, 2020
1 parent d81c8bf commit 0ef4211
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 21 deletions.
40 changes: 33 additions & 7 deletions docs/head/rstest/attr.rstest.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `rstest` attr in crate `rstest`."><meta name="keywords" content="rust, rustlang, rust-lang, rstest"><title>rstest::rstest - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc attr"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../rstest/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class='location'><a href='index.html'>rstest</a></p><script>window.sidebarCurrent = {name: 'rstest', ty: 'attr', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/rstest/lib.rs.html#688-709' title='goto source code'>[src]</a></span><span class='in-band'>Attribute Macro <a href='index.html'>rstest</a>::<wbr><a class="attr" href=''>rstest</a></span></h1><pre class='rust attr'>#[rstest]</pre><div class='docblock'><p>The attribute that you should use for your tests. Your
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `rstest` attr in crate `rstest`."><meta name="keywords" content="rust, rustlang, rust-lang, rstest"><title>rstest::rstest - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc attr"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../rstest/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class='location'><a href='index.html'>rstest</a></p><script>window.sidebarCurrent = {name: 'rstest', ty: 'attr', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/rstest/lib.rs.html#722-743' title='goto source code'>[src]</a></span><span class='in-band'>Attribute Macro <a href='index.html'>rstest</a>::<wbr><a class="attr" href=''>rstest</a></span></h1><pre class='rust attr'>#[rstest]</pre><div class='docblock'><p>The attribute that you should use for your tests. Your
annotated function's arguments can be
<a href="attr.rstest.html#injecting-fixtures">injected</a> with
<a href="../rstest/attr.fixture.html"><code>[fixture]</code></a>s, provided by
Expand Down Expand Up @@ -38,6 +38,9 @@ <h2 id="general-syntax" class="section-header"><a href="#general-syntax">General
<li>return results</li>
<li>marked by <code>#[should_panic]</code> attribute</li>
</ul>
<p>If the test function is an <a href="#async"><code>async</code> function</a> <code>rstest</code> will run all tests as <code>async</code>
tests. You can use it just with <code>async-std</code> and you should include <code>attributes</code> in
<code>async-std</code>'s features.</p>
<h2 id="injecting-fixtures" class="section-header"><a href="#injecting-fixtures">Injecting Fixtures</a></h2>
<p>The simplest case is write a test that can be injected with
<a href="../rstest/attr.fixture.html"><code>[fixture]</code></a>s. You can just declare all used fixtures by passing
Expand Down Expand Up @@ -159,17 +162,17 @@ <h3 id="optional-case-description" class="section-header"><a href="#optional-cas
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
</code></pre>
<h3 id="use-specific-case-attributes" class="section-header"><a href="#use-specific-case-attributes">Use specific <code>case</code> attributes</a></h3>
<p>Every function's attributes that follow the <code>rstest</code> one will
used in tests but you can also define a <code>case</code>'s attributes set.
This feature can be use to mark just some cases as <code>should_panic</code>
<p>Every function's attributes that follow the <code>rstest</code> one will
used in tests but you can also define a <code>case</code>'s attributes set.
This feature can be use to mark just some cases as <code>should_panic</code>
and chose to have a fine grain on expected panic messages.</p>
<p>In follow example we run 3 tests where the first pass without any
panic, in the second we catch a panic but we don't care about the message
panic, in the second we catch a panic but we don't care about the message
and in the third one we also check the panic message.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">rstest</span>::<span class="ident">rstest</span>;

<span class="attribute">#[<span class="ident">rstest</span>(
<span class="ident">val</span>,
<span class="ident">case</span>::<span class="ident">no_panic</span>(<span class="number">0</span>),
Expand All @@ -191,7 +194,7 @@ <h3 id="use-specific-case-attributes" class="section-header"><a href="#use-speci
test attribute_per_case::case_1_no_panic ... ok
test attribute_per_case::case_3_panic_with_message ... ok
test attribute_per_case::case_2_panic ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
</code></pre>
<h2 id="values-lists" class="section-header"><a href="#values-lists">Values Lists</a></h2>
Expand Down Expand Up @@ -227,6 +230,29 @@ <h2 id="values-lists" class="section-header"><a href="#values-lists">Values List

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
</code></pre>
<h2 id="async" class="section-header"><a href="#async">Async</a></h2>
<p><code>rstest</code> provide an out of the box <code>async</code> support. Just mark your
test function as async and test'll use <code>#[async-std::test]</code> to
annotate it. This feature can be really useful to build async
parametric tests by a really clean syntax:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">rstest</span>::<span class="kw-2">*</span>;

<span class="attribute">#[<span class="ident">rstest</span>(<span class="ident">expected</span>, <span class="ident">a</span>, <span class="ident">b</span>,
<span class="ident">case</span>(<span class="number">5</span>, <span class="number">2</span>, <span class="number">3</span>),
<span class="attribute">#[<span class="ident">should_panic</span>]</span>
<span class="ident">case</span>(<span class="number">42</span>, <span class="number">40</span>, <span class="number">1</span>)
)]
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">my_async_test</span>(<span class="ident">expected</span>: <span class="ident">u32</span>, <span class="ident">a</span>: <span class="ident">u32</span>, <span class="ident">b</span>: <span class="ident">u32</span>) {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">expected</span>, <span class="ident">async_sum</span>(<span class="ident">a</span>, <span class="ident">b</span>).<span class="kw">await</span>);
}</pre></div>
<p>By now you cannot write async <code>#[fixture]</code> and just <code>async-std</code> support
is provided but in the future will come <code>tokio</code>, custom runners and
<code>async</code> fixtures.</p>
<p>To use this feature you should use <code>attributes</code> in <code>async-std</code> fetures:</p>
<pre><code class="language-toml">async-std = { version=&quot;1.5&quot;, features = [&quot;attributes&quot;] }
</code></pre>
<h2 id="putting-all-together" class="section-header"><a href="#putting-all-together">Putting all Together</a></h2>
<p>All these features can be used together: take some fixtures, define some
fixed cases and, for each case, tests all combinations of given values.
Expand Down
2 changes: 1 addition & 1 deletion docs/head/rstest/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `rstest` crate."><meta name="keywords" content="rust, rustlang, rust-lang, rstest"><title>rstest - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../rstest/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate rstest</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all rstest's items</p></a><p class='location'></p><script>window.sidebarCurrent = {name: 'rstest', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/rstest/lib.rs.html#1-709' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>rstest</a></span></h1><div class='docblock'><p>This crate will help you to write simpler tests by leveraging a software testing concept called
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `rstest` crate."><meta name="keywords" content="rust, rustlang, rust-lang, rstest"><title>rstest - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../rstest/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate rstest</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all rstest's items</p></a><p class='location'></p><script>window.sidebarCurrent = {name: 'rstest', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/rstest/lib.rs.html#1-743' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>rstest</a></span></h1><div class='docblock'><p>This crate will help you to write simpler tests by leveraging a software testing concept called
<a href="https://en.wikipedia.org/wiki/Test_fixture#Software">test fixtures</a>. A fixture is something
that you can use in your tests to encapsulate a test's dependencies.</p>
<p>The general idea is to have smaller tests that only describe the thing you're testing while you
Expand Down
Loading

0 comments on commit 0ef4211

Please sign in to comment.