StyraInc / rego-style-guide

Style guide for Rego

Home Page:https://docs.styra.com/opa/rego-style-guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best practices for unit testing

anderseknert opened this issue · comments

Some thoughts

  • Extend general advice to recommend test driven development
  • And add an "Exceptions" part to the recommendation on imports stating that importing rules directly is fine for tests.

Test section

  • Use different package name, and imports, for tests
    • Recommendation for naming test packages: same as the package under test, with either .test or _test appended?
    • Recommendation for naming test files: _test.rego suffix?

Additionally, I've seen a few questions about how to best organize tests, i.e. should they be in the same directory as packages being tested, or in a separate one? While not strictly about "Rego" the language, I think it makes sense to consider this for the guide as well.