diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index bcf050adf0..04465dd53e 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -267,6 +267,11 @@ itest!(exit_sanitizer { exit_code: 1, }); +itest!(junit { + args: "test --reporter junit test/pass.ts", + output: "test/pass.junit.out", +}); + itest!(clear_timeout { args: "test test/clear_timeout.ts", exit_code: 0, diff --git a/cli/tests/testdata/test/pass.junit.out b/cli/tests/testdata/test/pass.junit.out new file mode 100644 index 0000000000..b652dbf85a --- /dev/null +++ b/cli/tests/testdata/test/pass.junit.out @@ -0,0 +1,38 @@ +Check [WILDCARD]/testdata/test/pass.ts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cli/tools/test/reporters/junit.rs b/cli/tools/test/reporters/junit.rs index eb6479a59f..a62c32dabb 100644 --- a/cli/tools/test/reporters/junit.rs +++ b/cli/tools/test/reporters/junit.rs @@ -40,13 +40,24 @@ impl JunitTestReporter { impl TestReporter for JunitTestReporter { fn report_register(&mut self, description: &TestDescription) { - self.cases.insert( - description.id, - quick_junit::TestCase::new( - description.name.clone(), - quick_junit::TestCaseStatus::skipped(), - ), + let mut case = quick_junit::TestCase::new( + description.name.clone(), + quick_junit::TestCaseStatus::skipped(), ); + let file_name = description.location.file_name.clone(); + let file_name = file_name.strip_prefix("file://").unwrap_or(&file_name); + case + .extra + .insert(String::from("filename"), String::from(file_name)); + case.extra.insert( + String::from("line"), + description.location.line_number.to_string(), + ); + case.extra.insert( + String::from("col"), + description.location.column_number.to_string(), + ); + self.cases.insert(description.id, case); } fn report_plan(&mut self, _plan: &TestPlan) {}