Skip to content

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

@inkarkat

Description

@inkarkat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions