Skip to content

Cargo book doesn't specify which tests run in parallel and which tests run in fresh environment #10361

Closed
@safinaskar

Description

@safinaskar

Hi. I aware of 3 types of tests in Rust: unit tests, integration tests and doctests. I would like to see in documentation for cargo test in Cargo book and in Rustdoc book the following info: whether this tests run in parallel and whether every test is run in fresh environment, i. e. in new process created specially for this test. Please note that "sequential execution" and "execution of each test in fresh environment" are different things. Consider unit tests run using cargo test -- --test-threads=1. As well as I understand they will be run sequentially, but they still be run in the same process, thus chdir and similar operations from one test will affect others. I want to see in cargo book and other docs answers to this questions:

  • Do unit tests run in parallel?
  • Does every unit test run in fresh environment?
  • Do integration tests (different #[test] functions from same file in tests) run in parallel?
  • Does every integration test (different #[test] functions from same file in tests) run in fresh environment?
  • Do integration tests from different files in tests run in parallel?
  • Does every integration test (from different files in tests) run in fresh environment?
  • Do doctests run in parallel?
  • Does every doctest run in fresh environment?

Currently I was able to easily find answers to first two questions. But docs are vague on others. Section https://doc.rust-lang.org/rustdoc/documentation-tests.html doesn't answer questions on doctests

(moved from rust-lang/book#3042 and slightly edited)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions