about summary refs log tree commit diff
path: root/src/doc/book/testing.md
AgeCommit message (Collapse)AuthorLines
2017-02-13Port TRPL to mdbookSteve Klabnik-633/+0
1. move everything under a src directory 2. add README.md to the SUMMARY.md
2017-02-02Rollup merge of #38823 - Freyskeyd:doc-missingInformationCfgTest, r=steveklabnikGuillaume Gomez-0/+4
Improve doc cfg(test) and tests directory Hi, I was facing a problem with my code organisation. I was using a tests directory and i defined some `#[cfg(test)]` in my `src/`. But i was not able to use it in my `tests` folder. ```bash . ├── Cargo.lock ├── Cargo.toml ├── src │   ├── lib.rs │   └── test.rs └── tests └── x.rs ``` > src/lib.rs ```rust pub mod test; fn tesst() { assert!(test::t()); } ``` > src/test.rs ```rust pub fn t() -> bool { true } ``` > test/x.rs ```rust extern crate testt; use testt::test; fn tesst() { assert!(test::t()); } ``` I was unable to compile using `cargo test`: ```bash error[E0432]: unresolved import `testt::test` --> tests/x.rs:3:5 | 3 | use testt::test; | ^^^^^^^^^^^ no `test` in `testt` ``` If i remove the `tests` directory everything works fine. To use an utils module in your `tests` directory, you need to create a module in the directory (like `tests/utils.rs`). My `tests/x.rs` look like this now: ```rust extern crate testt; mod utils; fn tesst() { assert!(utils::t()); } ``` And my tree: ```bash . ├── Cargo.lock ├── Cargo.toml ├── src │   └── lib.rs └── tests ├── utils.rs └── x.rs ``` I think that thing must be documented in the book. Ping: - @badboy : Because he's the one who showed me the path - @shahn : Because he helped me too to find the solution Signed-off-by: Freyskeyd <simon.paitrault@iadvize.com>
2017-01-24fix book: refer to `add_two` as "tested function"Raphael Das Gupta-1/+1
rather than "test function", which would be `it_works`
2017-01-24Fix doc cfg(test) and tests directoryFreyskeyd-0/+4
Signed-off-by: Freyskeyd <simon.paitrault@iadvize.com>
2016-12-13Simplify notes on testing and concurrencyWesley Moore-5/+4
2016-12-01Minor fix to testing concurrency sectionSteve Smith-5/+5
2016-11-17Rollup merge of #37766 - tarka:book-testing-concurrency-capture, r=steveklabnikGuillaume Gomez-0/+42
Add sections about testing concurrency and stdout/err capture
2016-11-14Remove thread-per-CPU bit as it may not be accurate.Steve Smith-6/+5
2016-11-14Typo in new sectionSteve Smith-1/+1
2016-11-14Add sections about concurrency and stdout/err capture to the Testing chapter ↵Steve Smith-0/+43
of the book.
2016-11-13Improved punctuation, capitalization, and sentence structure of code snippet ↵Angelo Polo-1/+1
comments
2016-11-10Ignore tests failing due to lack of `fn main`Trotter Cashion-7/+9
While the commit message on this one sounds terrible, it's really not so bad. The issue is that our test runner _expects_ a `fn main() {}` in code blocks that it'll test, but this code really shouldn't have them. If it did, then clicking the "play" link in the docs would result in play.rust-lang.org not treating this code as a test example to be run.
2016-11-10Remove extraneous wordTrotter Cashion-1/+1
2016-11-10Change project path for consistencyTrotter Cashion-5/+5
I had used `/tmp/adder` for my previous commits. Flipped over to `/home/you/projects/adder` for consistency with other parts of testing.md
2016-11-10Remove `mod tests` from earlier sectionsTrotter Cashion-62/+51
The narrative flows better if we follow what @steveklabnik is doing in rust-lang/book#288. Therefore, I completely copied it.
2016-11-10Instruct play.rust-lang.org to treat code as testsTrotter Cashion-2/+46
Without these changes, play.rust-lang.org (as of today) would wrap our examples in `fn main() {}`. This prevents the user from being able to easily run the tests.
2016-11-08Update testing.md to reflect changes to cargo newTrotter Cashion-50/+76
`cargo new` now creates a `src/lib.rs` with a `tests` module by default. I've updated the earlier examples in this doc to reflect this. However, I don't know how we want to approach the "introduction" to idiomatic testing that follows in "the tests module" section. I _think_ it should be broken apart, with the module concept being introduced early on, and the `super` concept being addressed when we hit the `add_two` example. I'd like to get agreement on that being the right approach before I do it though. I _also_ removed the `#fn main() {}` hidden at the beginning of each example, as these cause Rust Playground to not treat the file as a set of tests that it can run. Removing it _should_ cause Rust Playground to display a "Test >" button in the top left when a user runs the code, which will allow them to see the test runner output.
2016-10-30Update "Testing" chapter for 1.12Pieter Frenssen-35/+39
I followed the "Testing" chapter using Rust 1.12.1 but there are some differences. By default the `tests` module is now also generated by `cargo new`, and the console output is updated.
2016-10-19Fix grammatical errors in `tests` directory docsPaul Osborne-3/+3
2016-07-03Fix a few typos in the docSylvestre Ledru-1/+1
2016-06-07Rollup merge of #34060 - JDemler:master, r=steveklabnikSteve Klabnik-4/+10
Improved documentation for tests/ directory This ambigouity problem was already discussed in the [forums](https://users.rust-lang.org/t/problem-using-external-modules-inside-integration-test-submodule/5312/6).
2016-06-03document of shared modules for integration testsJakob Demler-2/+7
2016-06-03Fixed ambiguous explanaiton of tests/ directoryJakob Demler-2/+3
2016-05-22Rename main thread from "<main>" to "main".Wangshan Lu-1/+1
Fix issue #33789
2016-05-11trivial fixes to documentation (book)bnewbold-2/+2
2016-03-08Remove final note from testing chapter.Pyfisch-4/+0
The information that documentation tests cannot be run in binary crates is already given at the beginning of the section.
2016-01-29Add main() so that examples workSteve Klabnik-0/+11
Rustdoc will automatically wrap things in main, but this doesn't work here. Fixes #31249
2016-01-09Remove many instances of 'just'Steve Klabnik-1/+1
Doing so is considered weaker writing. Thanks @Charlotteis! Fixes #28810
2015-12-11book: Add missing punctuationOri Avtalion-1/+1
2015-11-19src/doc/trpl -> src/doc/bookSteve Klabnik-0/+510
The book was located under 'src/doc/trpl' because originally, it was going to be hosted under that URL. Late in the game, before 1.0, we decided that /book was a better one, so we changed the output, but not the input. This causes confusion for no good reason. So we'll change the source directory to look like the output directory, like for every other thing in src/doc.