Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Display a summary of all tests at the end #7835

Closed
ArekPiekarz opened this issue Jan 26, 2020 · 1 comment
Closed

Feature request: Display a summary of all tests at the end #7835

ArekPiekarz opened this issue Jan 26, 2020 · 1 comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@ArekPiekarz
Copy link

Describe the problem you are trying to solve

Currently cargo test doesn't show how many tests were executed as a whole, it only prints separate sums of parts during its run. This is a problem for a few reasons:

  • when writing new tests or refactoring the folder and file structure of them, it's important to validate that the expected number of tests were found and executed by cargo
  • in CI, it's helpful to monitor changes in number of executions, especially sudden abnormalities
  • each party interested in this information has to resort to custom scripts for parsing cargo test output, which may not have stability guarantees for its format and does not provide output specifically for machines

For example, right now the output of running tests looks something like this in one of my projects:

cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.24s
     Running target/debug/deps/app-8c1045fb0e6ad4a5

running 4 tests
test module_name::tests::foo ... ok
(...)
test module_name::tests::bar ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/integration_test_baz-dfdc5981450fbc5e

running 1 test
test integration_test_baz ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

(...)

     Running target/debug/deps/integration_test_something-b4e63349a484d05d

running 1 test
test integration_test_something ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests app

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Notice how every integration test is followed by:
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
At the end we can always see
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
because that project doesn't have doc tests, even though a lot of unit and integration tests were executed.

Describe the solution you'd like

At the end cargo test could print a summary of all executed tests like this (assuming 40 unit and 17 integration tests passed):

Summary: ok. 57 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Alternatively, it could split the summary into categories:

Summary:

       Unit tests: ok. 40 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Integration tests: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
        Doc tests: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
              All: ok. 57 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

The exact formatting is up for debate.

@ArekPiekarz ArekPiekarz added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 26, 2020
@ArekPiekarz ArekPiekarz changed the title Display a summary of all tests at the end Feature request: Display a summary of all tests at the end Jan 26, 2020
@ehuss
Copy link
Contributor

ehuss commented Jan 26, 2020

Thanks for the report. Closing as a duplicate of #4324. Cargo would need to use the libtest json output, and it's currently unstable and I'm not sure what else would need to be addressed.

@ehuss ehuss closed this as completed Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants