File tree 1 file changed +27
-3
lines changed
1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -595,10 +595,34 @@ if File.file?(rf_report)
595
595
end
596
596
msg = node . text . sub ( /\. $/ , '' )
597
597
msg = msg . split ( /\n / ) . delete_if { |el | el =~ /^(Build|System|Driver) info:/ } . join ( "\n " )
598
- file = suite [ 'source' ] . sub ( pwd , '' )
599
- file = github . html_link ( file )
598
+ scenario_file = suite [ 'source' ]
599
+ file = scenario_file . sub ( pwd , '' )
600
600
testcase = node . parent [ 'name' ]
601
- # TODO: try to findout the test case and use it for highlighting line numbers
601
+
602
+ # locate the lines of a test case in a test suite
603
+ from_line = -1
604
+ to_line = -1
605
+ current_line = 0
606
+ File . readlines ( scenario_file ) . each do |line |
607
+ current_line += 1
608
+ line . rstrip!
609
+
610
+ if line == testcase
611
+ from_line = current_line
612
+ next
613
+ end
614
+
615
+ if from_line > 0 && line == ''
616
+ to_line = current_line - 1
617
+ break
618
+ end
619
+ end
620
+
621
+ line = ''
622
+ if from_line > 0 && to_line > 0
623
+ line = "#L#{ from_line } -L#{ to_line } "
624
+ end
625
+ file = github . html_link ( "#{ file } #{ line } " )
602
626
fail ( "robotframework-maven-plugin error in #{ file } :\n Test case `#{ testcase } ` fails with message:\n #{ msg } " )
603
627
end
604
628
# TODO: add link to wiki page (#530)
You can’t perform that action at this time.
0 commit comments