当前位置:网站首页>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
边栏推荐
- VFS appears when mounting a file system from an SD card: cannot open root device "mmcblk1p2“
- IPtables
- Is Galaxy Securities reliable? Is it safe to open a securities account?
- Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
- The SH runtime directly reported an error syntax error near unexpected token ` $'. \r‘
- Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!
- [nailing scenario capability package] enterprise and public institution intelligent access control
- Record some questions about MySQL (DNS reverse resolution in Linux)
- UDP Vs TCP (Powercert animated videos)
- couldn‘t be accessed by user ‘_ apt‘
猜你喜欢

Openocd adds third-party device support: ht32f52352 Cortex-M0+

IPv4 and IPv6 (powercert animated videos)

Unable to connect to the server remotely locally using the Jupiter notebook

The correct way to clear the cache of the computer. The computer will not get stuck immediately after changing. practical

Heavy update! Yolov4 latest paper! Interpreting yolov4 framework

Molecular dynamics - basic characteristics of molecular force field

Getting started and using postman

Install JDK, MySQL and nexus under Linux (tar package installation)

Insert and update each database

After 20 days' interview, I finally joined Ali (share the interview process)
随机推荐
Getting started and using postman
01 network basics
After 20 days' interview, I finally joined Ali (share the interview process)
Molecular dynamics - basic characteristics of molecular force field
Order by keyword syntax problems encountered in SQL Server learning
Must see the summary! In depth learning era, you should read 10 articles to understand image classification!
Openocd adds third-party device support: ht32f52352 Cortex-M0+
Those high-frequency and real software test interview questions sorted out by the test director in 7 days, come to get
[nail scenario capability package] hospital visitor verification
[nailing scenario capability package] ranking of enterprise employees' points
炒股票用指南针安全还是用证券软件安全?哪里可以开户怎么开
Server pressure troubleshooting top
Docker Alpine image installation PHP extension redis
Is it safe for qiniu school to open an account in 2022?
Lesson 1 Preparation
同花顺炒股软件开户是合法的吗?安全吗
Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!
ThreadLocal class
[machine learning] machine learning from zero to mastery -- teach you to recognize handwritten digits using KNN
Insert picture in markdown