Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mapping tests stale naming bug #1014

Merged
merged 3 commits into from
Aug 29, 2023
Merged

Fix mapping tests stale naming bug #1014

merged 3 commits into from
Aug 29, 2023

Conversation

ka3de
Copy link
Collaborator

@ka3de ka3de commented Aug 29, 2023

What?

Fixes the mapping layer tests in order to use the subtest testing.T reference so the subtest name is identified on failure and therefore there is no need to reference the specific type through reflection.

Previous error message on a subtest failure:

--- FAIL: TestMappings (0.00s) // --> Does not reference the specific subtest
    /home/ka3de/devel/go/src/github.com/grafana/xk6-browser/browser/mapping_test.go:111: method on for Browser not found
FAIL
FAIL	github.com/grafana/xk6-browser/browser	0.008s
FAIL

Current error message:

--- FAIL: TestMappings (0.00s)
    --- FAIL: TestMappings/browser (0.00s)
        /home/ka3de/devel/go/src/github.com/grafana/xk6-browser/browser/mapping_test.go:194: method "on" not found
FAIL
FAIL	github.com/grafana/xk6-browser/browser	0.007s
FAIL

Why?

Previous behavior was not correct and required the actual type name specification in the error message through reflection in order to understand which was the failing test.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

The helper function was capturing the "global" test variable instead of
the one passed to t.Run(), which was causing every test failure from the
helper function to not identify the subtest name.
This is unnecessary now as failing from within the helper function will
reference the subtest name.
Use quotes to identify the conflict methods.
@ka3de ka3de added the bug Something isn't working label Aug 29, 2023
@ka3de ka3de self-assigned this Aug 29, 2023
@ka3de ka3de requested a review from inancgumus August 29, 2023 07:23
@ka3de ka3de mentioned this pull request Aug 29, 2023
3 tasks
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 This was a nice catch. IDK how we missed it. Thanks!

One downside of the anonymous interface is it won't get along with custom mappings. As I said here, we can take care of it later.

browser/mapping_test.go Show resolved Hide resolved
browser/mapping_test.go Show resolved Hide resolved
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ka3de ka3de merged commit e7d470b into main Aug 29, 2023
12 checks passed
@ka3de ka3de deleted the fix/mapping-test branch August 29, 2023 10:34
@inancgumus inancgumus changed the title Fix mapping tests Fix mapping tests stale naming bug Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants