Generating a documentation for tests

During the development of embedded software, Quality or certifications teams need a quick overview of the tests of a project. Typical relevant information are what, how and why a test tests.

This information can easily be written as markdown in the documentation of a test function but the current rustdoc/cargo doc excludes all modules and functions marked as #[test] for the generation of the documentation.

We would like to add a new option to rustdoc/cargo so that the tests are not filtered out during documentation generation. Additionally the test functions would be grouped in a paragraph called "Tests" instead of being added to the "Function" paragraph.

We have a proof of concept in this repo. In this POC in the branch test_documentation we added the option --document-tests for rustdoc. When this option is set :

  • the test modules are not filtered out of the documentation,
  • the test functions are gathered in a category called tests.

A limitation in this proof of concept is that integration tests are not added to the produced documentation.

An example project of the documentation can be found at demo. The generated doc is located in the usual folder target/doc.

We would like to have feedback and idea on how to manage the integration tests.

10 Likes