From 8f0d324358ba90b32b096f87971a723853e08da3 Mon Sep 17 00:00:00 2001 From: richard elms Date: Wed, 8 Jan 2025 17:34:53 +0100 Subject: [PATCH] simpler check [full ci] --- features/android/android_jvm_errors.feature | 10 +++--- features/steps/unity_steps.rb | 35 ++------------------- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/features/android/android_jvm_errors.feature b/features/android/android_jvm_errors.feature index 291ac5f2..34b990ae 100644 --- a/features/android/android_jvm_errors.feature +++ b/features/android/android_jvm_errors.feature @@ -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 @@ -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 diff --git a/features/steps/unity_steps.rb b/features/steps/unity_steps.rb index 567e6159..45b7bb6d 100644 --- a/features/steps/unity_steps.rb +++ b/features/steps/unity_steps.rb @@ -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') @@ -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