Skip to content

Commit

Permalink
simpler check [full ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
richardelms committed Jan 8, 2025
1 parent de5f34d commit 8f0d324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
10 changes: 6 additions & 4 deletions features/android/android_jvm_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ Feature: Android JVM Exceptions
# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
And the event "exceptions.0.stacktrace.0.method" equals "com.example.bugsnagcrashplugin.CrashHelper.triggerJvmException()"
And the stack frame files should match:
| CrashHelper.java | SourceFile |
And the exception "stacktrace.0.file" equals one of:
| CrashHelper.java |
| SourceFile |
And the error payload field "events.0.exceptions.0.stacktrace.0.lineNumber" is a number
And the error payload field "events.0.threads" is null

Expand Down Expand Up @@ -62,8 +63,9 @@ Feature: Android JVM Exceptions

# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
And the stack frame files should match:
| CrashHelper.java | SourceFile |
And the exception "stacktrace.0.file" equals one of:
| CrashHelper.java |
| SourceFile |
And the error payload field "events.0.exceptions.0.stacktrace.0.lineNumber" is a number
And the error payload field "events.0.threads" is not null

Expand Down
35 changes: 3 additions & 32 deletions features/steps/unity_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,6 @@ def check_error_reporting_api(notifier_name)
end
end

Then('the stack frame files should match:') do |expected_values|
stacktrace = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], 'events.0.exceptions.0.stacktrace')
expected_frame_values = expected_values.raw

flunk('The stacktrace is empty') if stacktrace.length == 0

files = stacktrace.map { |item| item['file'] }

expected_frame_values.each do |expected_frames|
file_index = 0
frame_matches = false
until frame_matches || file_index.eql?(files.size)
file = files[file_index]
frame_matches = expected_frames.any? { |frame| frame == file }
file_index += 1
end
Maze.check.true(frame_matches, "None of the files match the expected frames #{expected_frames}")
end
end

Then('the current error request events match one of:') do |table|
events = Maze::Server.errors.all.map do |error|
Maze::Helper.read_key_path(error[:body], 'events')
Expand Down Expand Up @@ -383,16 +363,7 @@ def switch_run_on_target
Maze.check.true(expected_values.include?(event_value), "Expected one of #{expected_values} but got #{event_value}")
end

When('the exception {string} equals one of:') do |path, table|
# Convert the table rows into a simple array of expected values
expected_values = table.raw.flatten

# Read the actual exception value from the Maze::Server error payload
actual_value = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], path)

# Check if the value is one of the expected values
Maze.check.true(
expected_values.include?(actual_value),
"Expected '#{actual_value}' to be one of #{expected_values}"
)
Then("the exception {string} equals one of:") do |keypath, possible_values|
value = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], "events.0.exceptions.0.#{keypath}")
Maze.check.include(possible_values.raw.flatten, value)
end

0 comments on commit 8f0d324

Please sign in to comment.