Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ jobs:
JWT_KEY: ${{ secrets.JWT_KEY }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}

- name: Upload Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: build/reports/**/*.xml

- name: Generate Report
if: ${{ always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) }}
uses: dorny/test-reporter@v2.0.0
with:
name: Tests
reporter: java-junit
path: build/reports/**/*.xml
token: ${{ secrets.GITHUB_TOKEN }}
57 changes: 54 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
require 'dotenv'
require 'simplecov'
require 'simplecov-lcov'
require 'warning'

require_relative '../lib/zitadel_client'

Warning.ignore(:method_redefined, __dir__)
Dotenv.load('.env')

# Configure the LCOV formatter
Expand Down Expand Up @@ -50,10 +53,58 @@ class HTMLFormatter

begin
require 'minitest/reporters'

module Minitest
module Reporters
# rubocop:disable Metrics/AbcSize,Style/Documentation,Metrics/MethodLength
class JUnitReporter
private

def parse_xml_for(xml, suite, tests)
suite_result = analyze_suite(tests)
file_path = get_relative_path(tests.first)

testsuite_attributes = {
name: suite,
file: file_path,
skipped: suite_result[:skip_count],
failures: suite_result[:fail_count],
errors: suite_result[:error_count],
tests: suite_result[:test_count],
assertions: suite_result[:assertion_count],
time: suite_result[:time],
timestamp: Time.now.iso8601,
hostname: Socket.gethostname
}
testsuite_attributes[:timestamp] = suite_result[:timestamp] if @timestamp_report

xml.testsuite(testsuite_attributes) do
tests.each do |test|
line = get_source_location(test).last
xml.testcase(
name: test.name,
line: line,
classname: suite,
assertions: test.assertions,
time: test.time,
file: file_path
) do
xml << xml_message_for(test) unless test.passed?
xml << xml_attachment_for(test) if test.respond_to?('metadata') && test.metadata[:failure_screenshot_path]
end
end
end
end
end
# rubocop:enable Metrics/AbcSize,Style/Documentation,Metrics/MethodLength
end
end

unless ENV['RM_INFO']
Minitest::Reporters.use!(
Minitest::Reporters::SpecReporter.new(color: true)
)
Minitest::Reporters.use! [
Minitest::Reporters::SpecReporter.new(color: true),
Minitest::Reporters::JUnitReporter.new('build/reports/', true, single_file: true)
]
end
rescue LoadError
warn 'minitest-reporters not available — install with `bundle add minitest-reporters`'
Expand Down
56 changes: 53 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'simplecov-lcov'
require_relative '../lib/zitadel_client'

Warning.ignore(:method_redefined, __dir__)
Dotenv.load('.env')

# Configure the LCOV formatter
Expand Down Expand Up @@ -51,10 +52,59 @@ class HTMLFormatter

begin
require 'minitest/reporters'

# 🔧 Monkeypatch to override :lineno with :line
module Minitest
module Reporters
# rubocop:disable Metrics/AbcSize,Style/Documentation,Metrics/MethodLength
class JUnitReporter
private

def parse_xml_for(xml, suite, tests)
suite_result = analyze_suite(tests)
file_path = get_relative_path(tests.first)

testsuite_attributes = {
name: suite,
filepath: file_path,
skipped: suite_result[:skip_count],
failures: suite_result[:fail_count],
errors: suite_result[:error_count],
tests: suite_result[:test_count],
assertions: suite_result[:assertion_count],
time: suite_result[:time],
timestamp: suite_result[:timestamp] || Time.now.iso8601,
hostname: Socket.gethostname
}
testsuite_attributes[:timestamp] = suite_result[:timestamp] if @timestamp_report

xml.testsuite(testsuite_attributes) do
tests.each do |test|
line = get_source_location(test).last
xml.testcase(
name: test.name,
line: line,
classname: suite,
assertions: test.assertions,
time: test.time,
file: file_path
) do
xml << xml_message_for(test) unless test.passed?
xml << xml_attachment_for(test) if test.respond_to?('metadata') && test.metadata[:failure_screenshot_path]
end
end
end
end
end
# rubocop:enable Metrics/AbcSize,Style/Documentation,Metrics/MethodLength
end
end

unless ENV['RM_INFO']
Minitest::Reporters.use!(
Minitest::Reporters::SpecReporter.new(color: true)
)
Minitest::Reporters.use! [
Minitest::Reporters::SpecReporter.new(color: true),
Minitest::Reporters::JUnitReporter.new('build/reports/', true, single_file: true)
]
end
rescue LoadError
warn 'minitest-reporters not available — install with `bundle add minitest-reporters`'
Expand Down