@@ -245,21 +245,33 @@ def mark_results(testrail_session: TestRail, test_results):
245
245
for result in existing_results [run_id ]
246
246
}
247
247
suite_id = test_results [category ][run_id ][0 ].get ("suite_id" )
248
- all_test_cases = [
249
- result .get ("test_case" ) for result in test_results [category ][run_id ]
250
- ]
248
+
249
+ all_test_cases = []
250
+ all_durations = []
251
+ for result in test_results [category ][run_id ]:
252
+ all_test_cases .append (result .get ("test_case" ))
253
+ all_durations .append (result .get ("duration" ))
251
254
252
255
# Don't set passed tests to another status.
253
- test_cases = [tc for tc in all_test_cases if current_results .get (tc ) != 1 ]
256
+ test_cases_ids = []
257
+ durations = []
258
+ for i , tc in enumerate (all_test_cases ):
259
+ if current_results .get (tc ) != 1 :
260
+ test_cases_ids .append (tc )
261
+ durations .append (all_durations [i ])
254
262
logging .warning (
255
- f"Setting the following test cases in run { run_id } to { category } : { test_cases } "
263
+ f"Setting the following test cases in run { run_id } to { category } : { test_cases_ids } "
264
+ )
265
+ logging .warning (
266
+ f"Setting the following test cases { test_cases_ids } to duration { durations } "
256
267
)
257
268
testrail_session .update_test_cases (
258
269
test_results .get ("project_id" ),
259
270
testrail_run_id = run_id ,
260
271
testrail_suite_id = suite_id ,
261
- test_case_ids = test_cases ,
272
+ test_case_ids = test_cases_ids ,
262
273
status = category ,
274
+ elapsed = durations
263
275
)
264
276
265
277
@@ -406,6 +418,7 @@ def organize_entries(testrail_session: TestRail, expected_plan: dict, suite_info
406
418
cases_in_suite = suite_info .get ("cases" )
407
419
cases_in_suite = [int (n ) for n in cases_in_suite ]
408
420
results = suite_info .get ("results" )
421
+ durations = suite_info .get ("durations" )
409
422
plan_title = expected_plan .get ("name" )
410
423
411
424
suite_entries = [
@@ -501,16 +514,18 @@ def organize_entries(testrail_session: TestRail, expected_plan: dict, suite_info
501
514
"skipped" : {},
502
515
}
503
516
504
- for test_case , outcome in results .items ():
505
- logging .info (f"{ test_case } : { outcome } " )
517
+ for test_case in results .keys ():
518
+ outcome = results [test_case ]
519
+ duration = durations [test_case ]
520
+ logging .info (f"{ test_case } : { outcome } { duration } " )
506
521
if outcome == "rerun" :
507
522
logging .info ("Rerun result...skipping..." )
508
523
continue
509
524
category = next (status for status in passkey if outcome in passkey .get (status ))
510
525
if not test_results [category ].get (run_id ):
511
526
test_results [category ][run_id ] = []
512
527
test_results [category ][run_id ].append (
513
- {"suite_id" : suite_id , "test_case" : test_case }
528
+ {"suite_id" : suite_id , "test_case" : test_case , "duration" : f" { duration } s" }
514
529
)
515
530
516
531
return test_results
@@ -546,7 +561,7 @@ def collect_changes(testrail_session: TestRail, report):
546
561
547
562
version_str = metadata .get ("fx_version" )
548
563
plan_title = get_plan_title (version_str , channel )
549
- logging .info ( plan_title )
564
+ logging .warning ( f"Got plan title: { plan_title } from version { version_str } and channel { channel } " )
550
565
plan_match = PLAN_NAME_RE .match (plan_title )
551
566
(_ , major ) = [plan_match [n ] for n in range (1 , 3 )]
552
567
config = metadata .get ("machine_config" )
@@ -627,6 +642,7 @@ def collect_changes(testrail_session: TestRail, report):
627
642
last_suite_id = None
628
643
last_description = None
629
644
results_by_suite = {}
645
+ durations_by_suite = {}
630
646
full_test_results = {}
631
647
tests = [
632
648
test
@@ -654,11 +670,16 @@ def collect_changes(testrail_session: TestRail, report):
654
670
# Tests reported as rerun are a problem -- we need to know pass/fail
655
671
if outcome == "rerun" :
656
672
outcome = test .get ("call" ).get ("outcome" )
657
- logging .info (f"TC: { test_case } : { outcome } " )
673
+ duration = test ['setup' ]['duration' ] + test ['call' ]['duration' ] + test ['teardown' ]['duration' ]
674
+ logging .info (f"TC: { test_case } : { outcome } using { duration } s " )
658
675
659
676
if not results_by_suite .get (suite_id ):
660
677
results_by_suite [suite_id ] = {}
678
+ durations_by_suite [suite_id ] = {}
661
679
results_by_suite [suite_id ][test_case ] = outcome
680
+ durations_by_suite [suite_id ].setdefault (test_case , 0 )
681
+ durations_by_suite [suite_id ][test_case ] = round (durations_by_suite [suite_id ][test_case ] + duration , 2 )
682
+
662
683
if suite_id != last_suite_id :
663
684
# When we get the last test_case in a suite, add entry, run, results
664
685
if last_suite_id :
@@ -673,6 +694,7 @@ def collect_changes(testrail_session: TestRail, report):
673
694
"config_id" : config_id ,
674
695
"cases" : cases_in_suite ,
675
696
"results" : results_by_suite [last_suite_id ],
697
+ "durations" : durations_by_suite [last_suite_id ]
676
698
}
677
699
678
700
full_test_results = merge_results (
@@ -693,6 +715,7 @@ def collect_changes(testrail_session: TestRail, report):
693
715
"config_id" : config_id ,
694
716
"cases" : cases_in_suite ,
695
717
"results" : results_by_suite [last_suite_id ],
718
+ "durations" : durations_by_suite [last_suite_id ]
696
719
}
697
720
698
721
logging .info (f"n run { last_suite_id } , { last_description } " )
@@ -705,6 +728,8 @@ def collect_changes(testrail_session: TestRail, report):
705
728
full_test_results = merge_results (
706
729
full_test_results , organize_entries (testrail_session , expected_plan , suite_info )
707
730
)
731
+ logging .warning (f"full test results: { full_test_results } " )
732
+
708
733
return full_test_results
709
734
710
735
0 commit comments