当前位置:网站首页>Ecu-test report converted to excel format
Ecu-test report converted to excel format
2022-06-25 21:21:00 【Pingshan 888 male technician】
ECU-TEST The report is transferred to Excel Format
ECU-TEST As an automated test execution software , It can be linked to many test tools , It is completely used Python To write , Officials have provided detailed information about ApiDoc Documents are available for users to consult . In the process of using the tool , The report generator encapsulated by the supplier to our company generates HTML Format , Although beautiful , But we can't see the passing of each test case more intuitively . At the same time, the report generally adopts PDF Format ,HTML There are many hyperlinks in the format report , A file cannot be overwritten , So I thought of using the official API Documents combine python Write a script , Let it output excel Report in format , The test engineer is converting to PDF that will do . Go straight to the code , The description has been explained in the notes .
2022-2-14 to update :ECU-TEST It can also generate excel The report , But there is only one layer project nesting , If there are two layers project The name of each nested test case is very verbose and cannot be arranged according to the system .
import sys
import openpyxl # Import the required package , Mainly openpyxl
from openpyxl.styles import PatternFill, Font
sys.path.append(r'D:\ECU_TEST 2020.4\Templates\ApiClient') # The path is Api File storage path , It is equivalent to all... Under this path py Documents are available
trf_path = r'D:\ECU_TEST 2020.4\TestReports\ Power control system .rtf' # This path is an automatically generated report file, i.e .trf(test report file)
from ApiClient import ApiClient
api = ApiClient # Call interface py file
wb = openpyxl.Workbook() # Create a table 、 Filling effect 、 typeface
ws = wb.active
ws.title = ' Test report '
fill1 = PatternFill('solid', fgColor='00FF00') # green
fill2 = PatternFill('solid', fgColor='FFFF00') # yellow
fill3 = PatternFill('solid', fgColor='FF0000') # Red
fill4 = PatternFill('solid', fgColor='C0C0C0') # gray
font1 = Font(name=u' Microsoft YaHei ', bold=True, size=14)
font2 = Font(name=u' Microsoft YaHei ', bold=True, size=12)
font3 = Font(name=u' Microsoft YaHei ', bold=False, size=10)
PASS = 0 # Specify four variables for statistical test results
FAIL = 0
ERROR = 0
NONE = 0
report = api.ReportApi.OpenReport(trf_path) # Get the report object
ex_time = report.GetExecutionTime() # execution time
main_project = report.GetMainProject() # Return to one project Object for subsequent operations
project_child = main_project.GetProjectElements() # This method obtains all children project Returns a list of all child objects
j = 0 # The outer loop
r = 8 # Number of lines to start
for name in project_child:
child_project_name = project_child[j].GetElementName() # Subsystem name
ws['A' + str(r)] = child_project_name
ws['A' + str(r)].font = font2
child_pkg = project_child[j].GetProjectElements() # Acquire subsystem , Get the object
i = 0 # Inner loop pointer
r = r + 1 # Write a line plus 1
for pkg in child_pkg:
child_pkg_name = child_pkg[i].GetElementName() # Get the case name
ws['B' + str(r)] = child_pkg_name
ws['B' + str(r)].font = font3
ws['C' + str(r)] = child_pkg[i].GetResult() # Get case results
if child_pkg[i].GetResult() == 'SUCCESS': # Fill cells with results
PASS = PASS + 1
ws['C' + str(r)].fill = fill1
if child_pkg[i].GetResult() == 'FAIL':
FAIL = FAIL + 1
ws['C' + str(r)].fill = fill2
if child_pkg[i].GetResult() == 'ERROR':
ERROR = ERROR + 1
ws['C' + str(r)].fill = fill3
if child_pkg[i].GetResult() == 'NONE':
NONE = None + 1
ws['C' + str(r)].fill = fill4
i = i + 1
r = r + 1
j = j + 1
ws['A1'] = ' Test date ' # Define some headers
ws['A1'].font = font1
ws['A2'] = ex_time
ws['A2'].font = font2
ws['B1'] = ' Total test duration '
ws['B1'].font = font1
ws['C1'] = ' Total number of test cases '
ws['C1'].font = font1
ws['A3'] = ' Passing number '
ws['A3'].font = font1
ws['B3'] = ' Number of failures '
ws['B3'].font = font1
ws['C3'] = ' Unexecuted amount '
ws['C3'].font = font1
ws['A5'] = ' Software coding '
ws['A5'].font = font1
ws['B5'] = ' Software version number '
ws['B5'].font = font1
ws['C5'] = ' Software pass rate '
ws['C5'].font = font1
ws['A7'] = ' The test system '
ws['A7'].font = font1
ws['C7'] = ' test result '
ws['C7'].font = font1
wb.save(' Test report .xlsx')
xlsx_file = r' Test report .xlsx' # You can't read and write at the same time , So in the previous step, save
rb = openpyxl.load_workbook(xlsx_file)
sheet1 = rb[' Test report '] # open sheet
sheet1['A4'] = PASS
sheet1['A4'].font = font2
sheet1['B4'] = FAIL + ERROR
sheet1['B4'].font = font2
sheet1['C4'] = NONE
sheet1['C4'].font = font2
sheet1['C2'] = PASS + ERROR + FAIL + NNONE
sheet1['C2'].font = font2
sheet1['C6'] = PASS / (FAIL + PASS + ERROR) # Unexecuted cases do not participate in the conclusion
sheet1['C6'].font = font2
rb.save(' Test report .xlsx')
# Please indicate the source of the original works
Please correct any deficiencies , thank
边栏推荐
- 同花顺炒股软件开户是合法的吗?安全吗
- C language soul torture: do you know the difference between the two?
- Heavy update! Yolov4 latest paper! Interpreting yolov4 framework
- Yolov4 reading notes (with mind map)! YOLOv4: Optimal Speed and Accuracy of Object Detection
- [nailing scenario capability package] enterprise and public institution intelligent access control
- [deep learning series] - visual interpretation of neural network
- couldn‘t be accessed by user ‘_ apt‘
- [nail scenario capability package] hospital visitor verification
- Vbpr (visual Bayesian personalized ranking) paper summary
- 启牛学堂证券开户安全嘛?
猜你喜欢

Writing manuals using markdown

On merging and sorting
![[opencv] opencv from introduction to mastery -- detailed explanation of input and output XML and yaml files](/img/88/75c4caacef30e0621106a4e3462367.jpg)
[opencv] opencv from introduction to mastery -- detailed explanation of input and output XML and yaml files

Getting started and using postman

Heavy update! Yolov4 latest paper! Interpreting yolov4 framework
![[nailing - scenario capability package] nailer card](/img/ec/c2f342a54ab69d8b834a8a1c8f8a01.jpg)
[nailing - scenario capability package] nailer card

Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!

Dbeaver offline installation driver

How to solve the problem of flash write protection in STM32?
![[nailing scenario capability package] smart office phone](/img/ec/c2f342a54ab69d8b834a8a1c8f8a01.jpg)
[nailing scenario capability package] smart office phone
随机推荐
JS__ Prototype, prototype chain, call/apply__ Duyi
ZABBIX foundation details
Getting started and using postman
Heavy update! Yolov4 latest paper! Interpreting yolov4 framework
[nailing scenario capability package] exhibition admission
The beginning of manjaro's journey
01 network basics
Molecular dynamics - basic characteristics of molecular force field
How to solve the problem of flash write protection in STM32?
Docker Alpine image installation PHP extension redis
Soft test intermediate simple notes
Install JDK, MySQL and nexus under Linux (tar package installation)
[phase 23] phased summary of spring recruitment practice (Alibaba cloud has OC)
Basic process of configuring utf8 in idea
Unable to connect to the server remotely locally using the Jupiter notebook
Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!
OBD Position Overview
Code program related problems troubleshooting directory
CANoe. Diva operation guide TP layer test
C language dynamic memory allocation