Ensure that all functionality, especially complex or quirky features, has corresponding unit tests. When adding new features or modifying existing code, proactively identify areas that lack test coverage and add appropriate tests.
Ensure that all functionality, especially complex or quirky features, has corresponding unit tests. When adding new features or modifying existing code, proactively identify areas that lack test coverage and add appropriate tests.
This is particularly important for:
For example, when adding flag parsing functionality:
#[test]
fn test_clean_command_parsing() {
// Test basic clean command
let mut flags = Flags::default();
let matches = /* create test matches */;
clean_parse(&mut flags, &matches);
assert_eq!(flags.subcommand, DenoSubcommand::Clean);
}
#[test]
fn test_clean_command_with_options() {
// Test clean command with various options
// ...
}
Or for utility functions:
#[test]
fn test_url_to_uri_conversion() {
// Test various URL formats
assert_eq!(url_to_uri(&url).unwrap(), expected_uri);
}
Don’t assume that functionality is “too simple” to test - utility functions, parsing logic, and similar features across a codebase should all have comprehensive test coverage to prevent regressions and ensure correctness.
Enter the URL of a public GitHub repository