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

[testing] print test case when an Invalid test fails for easier debug #137

Merged
merged 2 commits into from
Sep 25, 2020

Conversation

jimmylai
Copy link
Contributor

Summary

Without this change, developer needs to use the test case count (3 for INVALID_3) to figure out which test case fails. It's not convenient when the rule has lots of test cases.

FAIL: test_INVALID_3 (fixit.common.testing.NoRedundantLambdaRule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 221, in test_method
    return getattr(self, custom_test_method_name)(data, rule, fixture_file)
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 90, in _test_method
    'Expected a report for this "invalid" test case. `self.report` was not called.',
AssertionError: 0 not greater than 0 : Expected a report for this "invalid" test case. `self.report` was not called.

With this change, the failed test case source code is included to make it more clear.

FAIL: test_INVALID_3 (fixit.common.testing.NoRedundantLambdaRule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 222, in test_method
    return getattr(self, custom_test_method_name)(data, rule, fixture_file)
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 91, in _test_method
    + 'not called:\n' + test_case.code,
AssertionError: 0 not greater than 0 : Expected a report for this "invalid" test case but `self.report` was not called:
lambda x: fun()

Test Plan

See the above.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 25, 2020
Copy link
Member

@zsol zsol left a comment

Choose a reason for hiding this comment

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

lgtm

@jimmylai jimmylai merged commit b4c28db into Instagram:master Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants