Skip to content

Commit 4f2068b

Browse files
committed
docs: Clarify that names must be unique
See #166
1 parent bd80ab8 commit 4f2068b

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

crates/libtest-json/event.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"type": "object",
140140
"properties": {
141141
"name": {
142+
"description": "An identifier that is unique across the entire run",
142143
"type": "string"
143144
},
144145
"mode": {
@@ -197,6 +198,7 @@
197198
"type": "object",
198199
"properties": {
199200
"name": {
201+
"description": "An identifier that is unique across the entire run",
200202
"type": "string"
201203
},
202204
"elapsed_s": {
@@ -225,6 +227,7 @@
225227
"type": "object",
226228
"properties": {
227229
"name": {
230+
"description": "An identifier that is unique across the entire run",
228231
"type": "string"
229232
},
230233
"kind": {
@@ -256,6 +259,7 @@
256259
"type": "object",
257260
"properties": {
258261
"name": {
262+
"description": "An identifier that is unique across the entire run",
259263
"type": "string"
260264
},
261265
"elapsed_s": {

crates/libtest-json/src/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl DiscoverStart {
123123
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
124124
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
125125
pub struct DiscoverCase {
126+
/// An identifier that is unique across the entire run
126127
pub name: String,
127128
#[cfg_attr(
128129
feature = "serde",
@@ -265,6 +266,7 @@ impl RunStart {
265266
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
266267
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
267268
pub struct CaseStart {
269+
/// An identifier that is unique across the entire run
268270
pub name: String,
269271
#[cfg_attr(
270272
feature = "serde",
@@ -308,6 +310,7 @@ impl CaseStart {
308310
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
309311
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
310312
pub struct CaseMessage {
313+
/// An identifier that is unique across the entire run
311314
pub name: String,
312315
pub kind: MessageKind,
313316
#[cfg_attr(
@@ -369,6 +372,7 @@ impl CaseMessage {
369372
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
370373
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
371374
pub struct CaseComplete {
375+
/// An identifier that is unique across the entire run
372376
pub name: String,
373377
#[cfg_attr(
374378
feature = "serde",

crates/libtest2-harness/src/case.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub trait Case: Send + Sync + 'static {
66
/// By convention this follows the rules for rust paths; i.e., it should be a series of
77
/// identifiers separated by double colons. This way if some test runner wants to arrange the
88
/// tests hierarchically it may.
9+
///
10+
/// Must be unique across the entire test run.
911
fn name(&self) -> &str;
1012
fn kind(&self) -> TestKind;
1113
fn source(&self) -> Option<&Source>;

crates/libtest2-mimic/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ pub struct Trial {
131131
}
132132

133133
impl Trial {
134+
/// Define a test case
135+
///
136+
/// `name` must be unique across the entire test run.
134137
pub fn test(
135138
name: impl Into<String>,
136139
runner: impl Fn(RunContext<'_>) -> Result<(), RunError> + Send + Sync + 'static,

0 commit comments

Comments
 (0)