Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Robot test reporter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CTI Tools
Robot test reporter
Commits
c08d321f
Commit
c08d321f
authored
4 years ago
by
brydenf
Browse files
Options
Downloads
Patches
Plain Diff
Added 2 columns to TestEntry: NFV API and Robot file
Signed-off-by:
Frank Bryden
<
Frank.Bryden@etsi.org
>
parent
f8e87a16
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
parseTestResults.py
+32
-18
32 additions, 18 deletions
parseTestResults.py
testEntry.py
+5
-3
5 additions, 3 deletions
testEntry.py
writeExcel.py
+11
-3
11 additions, 3 deletions
writeExcel.py
with
48 additions
and
24 deletions
parseTestResults.py
+
32
−
18
View file @
c08d321f
...
...
@@ -15,8 +15,8 @@ Usage
python parseTestResults.py output.xml
where output.xml is the xml file generated by robot
The command outputs to a new xlslx file if it does not exist, or
appends to an existing one.
"""
...
...
@@ -38,32 +38,46 @@ class TestOutputParser:
def
run_parser
(
self
):
soup
=
BeautifulSoup
(
self
.
contents
,
"
lxml
"
)
# Suite information
suite
=
soup
.
find
(
"
suite
"
)
path
=
suite
[
"
source
"
]
# TODO This might be an issue later on. In Unix-style paths the separator is a forward slash
parts
=
path
.
split
(
"
\\
"
)
# Extract info for test entries
self
.
api
=
parts
[
len
(
parts
)
-
2
]
self
.
robotFile
=
parts
[
len
(
parts
)
-
1
]
# Tests
tests
=
soup
.
find_all
(
"
test
"
)
for
test
in
tests
:
self
.
testEntries
.
append
(
createTestEntry
(
test
))
self
.
testEntries
.
append
(
self
.
createTestEntry
(
test
))
# Write tests
ew
=
ExcelWriter
()
for
entry
in
self
.
testEntries
:
ew
.
writeTestEntry
(
entry
)
ew
.
save
()
def
createTestEntry
(
self
,
xmlObj
):
"""
Takes the xml entry corresponding to the test from the output file,
and returns a TestEntry object with the relevant information extracted.
"""
# retrieve ID and name
idRaw
=
xmlObj
.
find
(
"
doc
"
,
recursive
=
False
).
contents
mg
=
re
.
search
(
r
"
Test ID: ([0-9\.]*)$
"
,
idRaw
[
0
].
string
,
re
.
MULTILINE
)
testId
=
mg
.
group
(
1
)
name
=
xmlObj
[
"
name
"
]
#retrieve status and error message (if FAIL)
statusObj
=
xmlObj
.
find
(
"
status
"
,
recursive
=
False
)
cts
=
statusObj
.
contents
errorMsg
=
cts
[
0
]
if
len
(
cts
)
>
0
else
""
def
createTestEntry
(
xmlObj
):
# retrieve ID and name
idRaw
=
xmlObj
.
find
(
"
doc
"
,
recursive
=
False
).
contents
mg
=
re
.
search
(
r
"
Test ID: ([0-9\.]*)$
"
,
idRaw
[
0
].
string
,
re
.
MULTILINE
)
testId
=
mg
.
group
(
1
)
name
=
xmlObj
[
"
name
"
]
#retrieve status and error message (if FAIL)
statusObj
=
xmlObj
.
find
(
"
status
"
,
recursive
=
False
)
cts
=
statusObj
.
contents
errorMsg
=
cts
[
0
]
if
len
(
cts
)
>
0
else
""
result
=
statusObj
[
"
status
"
]
return
TestEntry
(
testId
,
name
,
result
,
errorMsg
)
result
=
statusObj
[
"
status
"
]
return
TestEntry
(
testId
,
name
,
result
,
errorMsg
,
self
.
api
,
self
.
robotFile
)
def
display_usage
():
print
(
usage_str
)
...
...
This diff is collapsed.
Click to expand it.
testEntry.py
+
5
−
3
View file @
c08d321f
class
TestEntry
:
def
__init__
(
self
,
id
,
name
,
result
,
errorMsg
=
""
):
def
__init__
(
self
,
id
,
name
,
result
,
errorMsg
,
api
,
robotFile
):
self
.
id
=
id
self
.
name
=
name
self
.
result
=
result
self
.
errorMsg
=
errorMsg
self
.
api
=
api
self
.
robotFile
=
robotFile
def
__str__
(
self
):
baseStr
=
"
[{}] {}:{}
"
.
format
(
self
.
id
,
self
.
name
,
self
.
result
)
if
self
.
errorMsg
!=
""
:
return
"
{}: {}
"
.
format
(
baseStr
,
self
.
errorMsg
)
return
"
{}: {}
({}/{})
"
.
format
(
baseStr
,
self
.
errorMsg
,
self
.
api
,
self
.
robotFile
)
else
:
return
baseStr
...
...
@@ -16,4 +18,4 @@ class TestEntry:
return
"
{}: {}
"
.
format
(
self
.
name
,
self
.
result
)
def
asList
(
self
):
return
[
self
.
id
,
self
.
name
,
self
.
result
,
self
.
errorMsg
]
\ No newline at end of file
return
[
self
.
id
,
self
.
name
,
self
.
result
,
self
.
errorMsg
,
self
.
api
,
self
.
robotFile
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
writeExcel.py
+
11
−
3
View file @
c08d321f
...
...
@@ -16,6 +16,13 @@ class ExcelWriter:
self
.
wb
=
getWorkbook
()
self
.
ws
=
self
.
wb
.
active
def
getEntryWithId
(
self
,
id
):
"""
When inserting an entry, it might be a test being re-run. In that case,
the row containing that test needs to be updated, as opposed to appending
the entry to the end of the file.
"""
def
getLastRow
(
self
):
for
cell
in
self
.
ws
[
"
A
"
]:
if
cell
.
value
is
None
:
...
...
@@ -25,7 +32,8 @@ class ExcelWriter:
def
writeTestEntry
(
self
,
testEntry
):
lastRow
=
self
.
getLastRow
()
cellCol
=
ExcelWriter
.
PASS_COL
if
testEntry
.
result
==
"
PASS
"
else
ExcelWriter
.
FAIL_COL
for
col
,
cellValue
in
zip
(
self
.
ws
.
iter_cols
(
min_row
=
lastRow
,
max_col
=
4
,
max_row
=
lastRow
),
testEntry
.
asList
()):
entryVals
=
testEntry
.
asList
()
for
col
,
cellValue
in
zip
(
self
.
ws
.
iter_cols
(
min_row
=
lastRow
,
max_col
=
len
(
entryVals
),
max_row
=
lastRow
),
entryVals
):
for
cell
in
col
:
cell
.
value
=
cellValue
cell
.
fill
=
PatternFill
(
"
solid
"
,
fgColor
=
cellCol
)
# cellCol
...
...
@@ -37,10 +45,10 @@ def initWorkbook(wb):
"""
Writes column headers to ws
"""
headers
=
[(
"
Test ID
"
,
10
),
(
"
Test name
"
,
80
),
(
"
Result
"
,
6
),
(
"
Error Message
"
,
100
)]
headers
=
[(
"
Test ID
"
,
10
),
(
"
Test name
"
,
80
),
(
"
Result
"
,
6
),
(
"
Error Message
"
,
100
)
,
(
"
NFV API
"
,
25
),
(
"
Robot Test File
"
,
25
)
]
headerFont
=
Font
(
bold
=
True
)
ws
=
wb
.
active
for
col
,
header
in
zip
(
ws
.
iter_cols
(
min_row
=
1
,
max_col
=
4
,
max_row
=
1
),
headers
):
for
col
,
header
in
zip
(
ws
.
iter_cols
(
min_row
=
1
,
max_col
=
len
(
headers
)
,
max_row
=
1
),
headers
):
for
cell
in
col
:
headerName
=
header
[
0
]
colsize
=
header
[
1
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment