Skip to content

Commit 40b6a6f

Browse files
Merge pull request #10 from timkrins/add-line-and-filepath
Add line and file if available
2 parents 5800c1a + 3633d69 commit 40b6a6f

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

src/convert.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface JUnitTestCase {
1616
errorTrace: string | undefined,
1717
errorMessage: string | undefined,
1818
errorType: string | undefined,
19+
file?: string,
20+
lineno?: string,
1921
skipped?: boolean;
2022
}
2123

@@ -28,7 +30,7 @@ async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[]> {
2830
const parseTestSuite = (suite: any, suiteName: string) => {
2931
if (suite.testcase) {
3032
suite.testcase.forEach((testCase: any) => {
31-
const { classname, name, time } = testCase.$;
33+
const { classname, file, lineno, name, time } = testCase.$;
3234

3335
const hasFailure = testCase.failure !== undefined;
3436
const failureTrace = hasFailure ? (testCase.failure[0]?._ || '') : undefined;
@@ -46,6 +48,8 @@ async function parseJUnitReport(filePath: string): Promise<JUnitTestCase[]> {
4648
classname,
4749
name,
4850
time,
51+
file,
52+
lineno,
4953
hasFailure,
5054
failureTrace,
5155
failureMessage,
@@ -101,10 +105,14 @@ function convertToCTRFTest(testCase: JUnitTestCase, useSuiteName: boolean): Ctrf
101105
? `${testCase.suite}: ${testCase.name}`
102106
: testCase.name;
103107

108+
const line = testCase.lineno ? parseInt(testCase.lineno) : undefined;
109+
104110
return {
105111
name: testName,
106112
status,
107113
duration: durationMs,
114+
filePath: testCase.file,
115+
line: line,
108116
message: testCase.failureMessage || testCase.errorMessage || undefined,
109117
trace: testCase.failureTrace || testCase.errorTrace || undefined,
110118
suite: testCase.suite || '',

test-minitest-junit.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0"?>
2+
<testsuites>
3+
<testsuite name="MinitestExample::ExampleOne" filepath="test/example_one_test.rb" skipped="0" failures="0" errors="0" tests="19" assertions="138" time="142.68252823400005">
4+
<testcase name="test_should_1" lineno="30" classname="MinitestExample::ExampleOne" assertions="9" time="18.851395190999995" file="test/example_one_test.rb"></testcase>
5+
<testcase name="test_should_2" lineno="163" classname="MinitestExample::ExampleOne" assertions="8" time="11.454658561999992" file="test/example_one_test.rb"></testcase>
6+
<testcase name="test_should_3" lineno="474" classname="MinitestExample::ExampleOne" assertions="16" time="10.002900208" file="test/example_one_test.rb"></testcase>
7+
<testcase name="test_should_4" lineno="417" classname="MinitestExample::ExampleOne" assertions="8" time="7.906220136000002" file="test/example_one_test.rb"></testcase>
8+
<testcase name="test_should_5" lineno="377" classname="MinitestExample::ExampleOne" assertions="3" time="4.83951247600001" file="test/example_one_test.rb"></testcase>
9+
<testcase name="test_should_6" lineno="127" classname="MinitestExample::ExampleOne" assertions="2" time="7.946934494999994" file="test/example_one_test.rb"></testcase>
10+
<testcase name="test_should_7" lineno="90" classname="MinitestExample::ExampleOne" assertions="6" time="7.33681554399999" file="test/example_one_test.rb"></testcase>
11+
<testcase name="test_should_8" lineno="361" classname="MinitestExample::ExampleOne" assertions="3" time="3.7035172650000163" file="test/example_one_test.rb"></testcase>
12+
<testcase name="test_should_9" lineno="792" classname="MinitestExample::ExampleOne" assertions="7" time="5.0982520260000115" file="test/example_one_test.rb"></testcase>
13+
<testcase name="test_should_10" lineno="565" classname="MinitestExample::ExampleOne" assertions="14" time="8.214560409" file="test/example_one_test.rb"></testcase>
14+
<testcase name="test_should_11" lineno="847" classname="MinitestExample::ExampleOne" assertions="4" time="3.7682949800000074" file="test/example_one_test.rb"></testcase>
15+
<testcase name="test_should_12" lineno="23" classname="MinitestExample::ExampleOne" assertions="3" time="2.9085229240000103" file="test/example_one_test.rb"></testcase>
16+
<testcase name="test_should_13" lineno="236" classname="MinitestExample::ExampleOne" assertions="8" time="7.498208777000002" file="test/example_one_test.rb"></testcase>
17+
<testcase name="test_should_14" lineno="645" classname="MinitestExample::ExampleOne" assertions="25" time="18.99167838599999" file="test/example_one_test.rb"></testcase>
18+
<testcase name="test_should_15" lineno="74" classname="MinitestExample::ExampleOne" assertions="2" time="2.9546497440000508" file="test/example_one_test.rb"></testcase>
19+
<testcase name="test_should_16" lineno="818" classname="MinitestExample::ExampleOne" assertions="7" time="5.090684646" file="test/example_one_test.rb"></testcase>
20+
<testcase name="test_should_17" lineno="80" classname="MinitestExample::ExampleOne" assertions="1" time="4.677773596000009" file="test/example_one_test.rb"></testcase>
21+
<testcase name="test_should_18" lineno="283" classname="MinitestExample::ExampleOne" assertions="9" time="7.857259849999991" file="test/example_one_test.rb"></testcase>
22+
<testcase name="test_should_19" lineno="336" classname="MinitestExample::ExampleOne" assertions="3" time="3.5806890189999763" file="test/example_one_test.rb"></testcase>
23+
</testsuite>
24+
<testsuite name="MinitestExample::ExampleTwo" filepath="test/example_two_test.rb" skipped="0" failures="0" errors="0" tests="14" assertions="92" time="71.78414915600013">
25+
<testcase name="test_should_100" lineno="95" classname="MinitestExample::ExampleTwo" assertions="5" time="2.827323084999989" file="test/example_two_test.rb"></testcase>
26+
<testcase name="test_should_101" lineno="319" classname="MinitestExample::ExampleTwo" assertions="10" time="1.8399586300000124" file="test/example_two_test.rb"></testcase>
27+
<testcase name="test_should_102" lineno="134" classname="MinitestExample::ExampleTwo" assertions="8" time="2.860204046999968" file="test/example_two_test.rb"></testcase>
28+
<testcase name="test_should_103" lineno="53" classname="MinitestExample::ExampleTwo" assertions="5" time="2.2035054890000083" file="test/example_two_test.rb"></testcase>
29+
<testcase name="test_should_104" lineno="289" classname="MinitestExample::ExampleTwo" assertions="7" time="2.7548382760000436" file="test/example_two_test.rb"></testcase>
30+
<testcase name="test_should_105" lineno="16" classname="MinitestExample::ExampleTwo" assertions="2" time="12.951703337000026" file="test/example_two_test.rb"></testcase>
31+
<testcase name="test_should_106" lineno="153" classname="MinitestExample::ExampleTwo" assertions="8" time="2.7291457330000526" file="test/example_two_test.rb"></testcase>
32+
<testcase name="test_should_107" lineno="243" classname="MinitestExample::ExampleTwo" assertions="8" time="3.1154159890000415" file="test/example_two_test.rb"></testcase>
33+
<testcase name="test_should_108" lineno="202" classname="MinitestExample::ExampleTwo" assertions="5" time="2.749787270000013" file="test/example_two_test.rb"></testcase>
34+
<testcase name="test_should_109" lineno="80" classname="MinitestExample::ExampleTwo" assertions="5" time="10.799018211000032" file="test/example_two_test.rb"></testcase>
35+
<testcase name="test_should_110" lineno="172" classname="MinitestExample::ExampleTwo" assertions="5" time="2.615235616999996" file="test/example_two_test.rb"></testcase>
36+
<testcase name="test_should_111" lineno="22" classname="MinitestExample::ExampleTwo" assertions="4" time="2.1280812749999996" file="test/example_two_test.rb"></testcase>
37+
<testcase name="test_should_112" lineno="31" classname="MinitestExample::ExampleTwo" assertions="2" time="2.2754831219999687" file="test/example_two_test.rb"></testcase>
38+
<testcase name="test_should_113" lineno="109" classname="MinitestExample::ExampleTwo" assertions="18" time="19.934449074999975" file="test/example_two_test.rb"></testcase>
39+
</testsuite>
40+
</testsuites>

types/ctrf.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface CtrfTest {
3232
suite?: string
3333
message?: string
3434
trace?: string
35+
line?: number
3536
rawStatus?: string
3637
tags?: string[]
3738
type?: string

0 commit comments

Comments
 (0)