Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e7fe1ea6
Commit
e7fe1ea6
authored
Apr 02, 2020
by
Maxime Orefice
Committed by
Shinya Maeda
Apr 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filtering ability for JUnit
Filter a TestReport by attachment Filter a TestSuite by attachment
parent
1ac0b06d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
0 deletions
+84
-0
lib/gitlab/ci/reports/test_reports.rb
lib/gitlab/ci/reports/test_reports.rb
+8
-0
lib/gitlab/ci/reports/test_suite.rb
lib/gitlab/ci/reports/test_suite.rb
+10
-0
spec/factories/ci/test_case.rb
spec/factories/ci/test_case.rb
+5
-0
spec/lib/gitlab/ci/reports/test_reports_spec.rb
spec/lib/gitlab/ci/reports/test_reports_spec.rb
+32
-0
spec/lib/gitlab/ci/reports/test_suite_spec.rb
spec/lib/gitlab/ci/reports/test_suite_spec.rb
+29
-0
No files found.
lib/gitlab/ci/reports/test_reports.rb
View file @
e7fe1ea6
...
...
@@ -34,6 +34,14 @@ module Gitlab
end
end
def
with_attachment!
@test_suites
.
keep_if
do
|
_job_name
,
test_suite
|
test_suite
.
with_attachment!
.
present?
end
self
end
TestCase
::
STATUS_TYPES
.
each
do
|
status_type
|
define_method
(
"
#{
status_type
}
_count"
)
do
# rubocop: disable CodeReuse/ActiveRecord
...
...
lib/gitlab/ci/reports/test_suite.rb
View file @
e7fe1ea6
...
...
@@ -37,6 +37,16 @@ module Gitlab
end
end
def
with_attachment!
@test_cases
=
@test_cases
.
extract!
(
"failed"
)
@test_cases
.
keep_if
do
|
status
,
hash
|
hash
.
any?
do
|
key
,
test_case
|
test_case
.
has_attachment?
end
end
end
TestCase
::
STATUS_TYPES
.
each
do
|
status_type
|
define_method
(
"
#{
status_type
}
"
)
do
test_cases
[
status_type
]
||
{}
...
...
spec/factories/ci/test_case.rb
View file @
e7fe1ea6
...
...
@@ -11,7 +11,12 @@ FactoryBot.define do
attachment
{
nil
}
association
:job
,
factory: :ci_build
trait
:failed
do
status
{
"failed"
}
end
trait
:with_attachment
do
status
{
"failed"
}
attachment
{
"some/path.png"
}
end
...
...
spec/lib/gitlab/ci/reports/test_reports_spec.rb
View file @
e7fe1ea6
...
...
@@ -109,6 +109,38 @@ describe Gitlab::Ci::Reports::TestReports do
end
end
describe
'#with_attachment'
do
let
(
:test_case
)
{
build
(
:test_case
,
:failed
)
}
subject
{
test_reports
.
with_attachment!
}
context
'when test suites do not contain an attachment'
do
before
do
test_reports
.
get_suite
(
'rspec'
).
add_test_case
(
create_test_case_rspec_success
)
test_reports
.
get_suite
(
'junit'
).
add_test_case
(
test_case
)
end
it
'returns empty test suites'
do
expect
(
subject
.
test_suites
).
to
be_empty
end
end
context
'when test suites contain an attachment'
do
let
(
:test_case_succes
)
{
build
(
:test_case
)
}
let
(
:test_case_with_attachment
)
{
build
(
:test_case
,
:with_attachment
)
}
before
do
test_reports
.
get_suite
(
'rspec'
).
add_test_case
(
test_case_succes
)
test_reports
.
get_suite
(
'junit'
).
add_test_case
(
test_case_with_attachment
)
end
it
'returns test suites with attachment'
do
expect
(
subject
.
test_suites
.
count
).
to
eq
(
1
)
expect
(
subject
.
test_suites
[
'junit'
].
test_cases
[
'failed'
]).
to
be_present
end
end
end
Gitlab
::
Ci
::
Reports
::
TestCase
::
STATUS_TYPES
.
each
do
|
status_type
|
describe
"#
#{
status_type
}
_count"
do
subject
{
test_reports
.
public_send
(
"
#{
status_type
}
_count"
)
}
...
...
spec/lib/gitlab/ci/reports/test_suite_spec.rb
View file @
e7fe1ea6
...
...
@@ -85,6 +85,35 @@ describe Gitlab::Ci::Reports::TestSuite do
end
end
describe
'#with_attachment'
do
subject
{
test_suite
.
with_attachment!
}
context
'when test cases do not contain an attachment'
do
let
(
:test_case
)
{
build
(
:test_case
,
:failed
)}
before
do
test_suite
.
add_test_case
(
test_case
)
end
it
'returns an empty hash'
do
expect
(
subject
).
to
be_empty
end
end
context
'when test cases contain an attachment'
do
let
(
:test_case_with_attachment
)
{
build
(
:test_case
,
:with_attachment
)}
before
do
test_suite
.
add_test_case
(
test_case_with_attachment
)
end
it
'returns failed test cases with attachment'
do
expect
(
subject
.
count
).
to
eq
(
1
)
expect
(
subject
[
'failed'
]).
to
be_present
end
end
end
Gitlab
::
Ci
::
Reports
::
TestCase
::
STATUS_TYPES
.
each
do
|
status_type
|
describe
"#
#{
status_type
}
"
do
subject
{
test_suite
.
public_send
(
"
#{
status_type
}
"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment