Skip to content

test tool should support test-only dependencies #1901

Description

@johngmyers

Feature Request

Is your feature request related to a problem? Please describe:

I want unit tests to use KCL modules that the module under test does not use. I do not want the module under test to require said dependency only because it is used in unit tests.

As an example: the existing unit test framework is very poor at providing information needed for a developer to diagnose why an assertion fails. The minimum expectation of a reasonable assertion would be to print the value of the "actual" upon failure. Better would be to print a diff between the "actual" and "expected" for assertions that have both.

The difflib module is the start of something that could be built into an assertions module, but the issue is how to get tests to depend on an assertions module without having the module under test depend on that same module.

Describe the feature you'd like:

Probably a [test_dependences] section in kcl.mod. This would be used by the kcl test command. It would probably also be updated by the kcl mod update command.

Possibly add a --test flag to kcl mod add.

Describe alternatives you've considered:

Users could make the package under test add the dependency. This is usually undesirable.

The language could create new variants of the assert command which do the comparisons and emit the output. But this would not allow the set of comparisons to be reasonably extended.

Print-a-diff could be put into the core language.

Teachability, Documentation, Adoption, Migration Strategy:

testing.assert_equal(actual, expected) would print a diff from expected to actual if the two values are not equal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttoolIssues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions