-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update testing guide structure and add coverage testing (#1182)
- Loading branch information
1 parent
077d942
commit f381246
Showing
10 changed files
with
63 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: Code Coverage | ||
hide_table_of_contents: true | ||
description: Code coverage tools find code not tested. | ||
sidebar_position: 10 | ||
--- | ||
|
||
Measuring code coverage uses tools to identify lines of code that are and aren't executed by tests. Code coverage stats can give us an idea of how much of a contract is actually tested by its tests. | ||
|
||
:::tip | ||
|
||
Mutation testing is another form of coverage testing. See [Mutation Testing]. | ||
|
||
::: | ||
|
||
In rust projects the `cargo-llvm-cov` tool can be used to generate coverage stats, HTML reports, and lcov files that IDEs will load to display the coverage in the code editor. | ||
|
||
Install `cargo-llvm-cov` before proceeding with the other commands. | ||
|
||
``` | ||
cargo install cargo-llvm-cov | ||
``` | ||
|
||
## How to Get Coverage Stats | ||
|
||
Run the test subcommand that will run the tests and output the stats per file. | ||
|
||
``` | ||
cargo llvm-cov test | ||
``` | ||
|
||
## How to Generate a Coverage Report with Code | ||
|
||
Run the test subcommand that will run the tests and output a set of HTML files showing which lines of code are covered. | ||
|
||
``` | ||
cargo llvm-cov test --html --open | ||
``` | ||
|
||
The output of the command will indicate where the HTML file has been written. Open the file in a browser. | ||
|
||
## How to Generate an LCOV File for IDEs | ||
|
||
Run the test subcommand that will run the tests and output a single `lcov.info` file. | ||
|
||
``` | ||
cargo llvm-cov test --lcov --output-path=lcov.info | ||
``` | ||
|
||
Load the `lcov.info` file into your IDE using it's coverage feature. In VSCode this can be done by installing the [Coverage Gutters] extension and executing the `Coverage Gutters: Watch` command. | ||
|
||
[Coverage Gutters]: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters | ||
[Mutation Testing]: mutation-testing.mdx |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters