Machine-readable output

cargo-nextest can be configured to produce machine-readable JSON output, readable by other programs. The nextest-metadata crate provides a Rust interface to deserialize the output to. (The same crate is used by nextest to generate the output.)

Listing tests

To produce a list of tests in the JSON output format cargo nextest list --message-format json (or json-pretty for nicely formatted output). Here’s some example output for the tokio repository:

  1. % cargo nextest list -p tokio-util --features full --lib --format json-pretty
  2. {
  3. "test-count": 4,
  4. "rust-suites": {
  5. "tokio-util": {
  6. "package-name": "tokio-util",
  7. "binary-name": "tokio-util",
  8. "package-id": "tokio-util 0.7.0 (path+file:///home/me/dev/tokio/tokio-util)",
  9. "binary-path": "/home/me/dev/tokio/target/debug/deps/tokio_util-def0ee51cb418fe8",
  10. "cwd": "/home/rain/dev/tokio/tokio-util",
  11. "testcases": {
  12. "either::tests::either_is_async_read": {
  13. "ignored": false,
  14. "filter-match": {
  15. "status": "matches"
  16. }
  17. },
  18. "either::tests::either_is_stream": {
  19. "ignored": false,
  20. "filter-match": {
  21. "status": "matches"
  22. }
  23. },
  24. "time::wheel::level::test::test_slot_for": {
  25. "ignored": false,
  26. "filter-match": {
  27. "status": "matches"
  28. }
  29. },
  30. "time::wheel::test::test_level_for": {
  31. "ignored": false,
  32. "filter-match": {
  33. "status": "matches"
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }

The value of "package-id" can be matched up to the package IDs produced by running cargo metadata.

Running tests

This is currently not implemented, but will be implemented in the near future.