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

Assertions are inconsistent with and more limited than bats-assert #67

Open
inkarkat opened this issue Jan 4, 2025 · 0 comments
Open

Comments

@inkarkat
Copy link

inkarkat commented Jan 4, 2025

I've started using bats-assert and am now looking into how bats-file can help with file-based assertions. As both libraries are built on bats-support (and have originated from the same author), I see these as closely related projects, and expect consistency in their APIs. However, there seem to be differences that make adoption harder:

  • bats-assert uses assert and refute to distinguish between positive and negative assertions, whereas bats-file uses assert_something and assert_not_something. For example, assert_file_not_exists should be named refute_file_exists to be consistent with bats-assert.
  • Some negative assertions are missing, e.g. there's no assert_file_size_not_equals (or rather refute_file_size_equals), and no refute_files_equal.
  • assert_file_contains only does regexp matching; the related assert_output from bats-assert offers complete equivalence, partial (but literal) matching, and regexp matching, making it far more versatile.

All of bats-file's assertions are thin wrappers around test commands; its main value is in providing a fluent, consistent, and discoverable API. I suggest to align the API with bats-assert, and to add the missing negative assertions and more matching options to assert_file_contains. This would make the library more powerful and easier to use for users already familiar with bats-assert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant