pub struct TestNode {Show 14 fields
pub node_id: TestNodeId,
pub kind: TestNodeKind,
pub file_path: String,
pub lineno: Option<u32>,
pub name: String,
pub class_name: Option<String>,
pub markers: Vec<String>,
pub keywords: Vec<String>,
pub parameters: Option<String>,
pub avg_duration_ms: Option<u64>,
pub run_count: u32,
pub fail_count: u32,
pub xfail: bool,
pub skip: bool,
}Expand description
A single test node with metadata.
Fields§
§node_id: TestNodeIdThe unique node ID (pytest format).
kind: TestNodeKindThe kind of node.
file_path: StringFile path relative to the repo root.
lineno: Option<u32>Line number where the test is defined (1-indexed).
name: StringThe test function/method name.
class_name: Option<String>Parent class name (if method).
markers: Vec<String>Markers attached to this test (e.g., “slow”, “skip”, “xfail”).
keywords: Vec<String>Keywords for -k filtering (includes name, class, markers, etc.).
parameters: Option<String>Parameter IDs if this is a parametrized test.
avg_duration_ms: Option<u64>Historical average duration in milliseconds.
run_count: u32Number of times this test has been run.
fail_count: u32Number of times this test has failed.
xfail: boolWhether this test is currently marked as expected to fail.
skip: boolWhether this test is currently skipped.
Implementations§
Source§impl TestNode
impl TestNode
Sourcepub fn new(node_id: impl Into<String>, file_path: impl Into<String>) -> Self
pub fn new(node_id: impl Into<String>, file_path: impl Into<String>) -> Self
Create a new test node with minimal information.
Sourcepub fn add_marker(&mut self, marker: impl Into<String>)
pub fn add_marker(&mut self, marker: impl Into<String>)
Add a marker to this test.
Sourcepub fn build_keywords(&mut self)
pub fn build_keywords(&mut self)
Build the keywords list for -k filtering.
Sourcepub fn matches_keyword(&self, expr: &str) -> bool
pub fn matches_keyword(&self, expr: &str) -> bool
Check if this test matches a keyword expression.
Simple implementation supporting:
- Plain keywords (substring match)
not keywordkeyword1 and keyword2keyword1 or keyword2
Sourcepub fn has_marker(&self, marker: &str) -> bool
pub fn has_marker(&self, marker: &str) -> bool
Check if this test has a specific marker.
Sourcepub fn matches_marker(&self, expr: &str) -> bool
pub fn matches_marker(&self, expr: &str) -> bool
Check if this test matches a marker expression.
Simple implementation supporting:
- Plain markers
not markermarker1 and marker2marker1 or marker2
Sourcepub fn record_duration(&mut self, duration_ms: u64)
pub fn record_duration(&mut self, duration_ms: u64)
Update duration statistics after a test run.
Sourcepub fn record_failure(&mut self)
pub fn record_failure(&mut self)
Record a test failure.
Sourcepub fn failure_rate(&self) -> f64
pub fn failure_rate(&self) -> f64
Get the failure rate as a percentage.