mgechev/revive

Replace existing tests that target unexported functions with tests for exported

開放

#1,362 建立於 2025年5月20日

 (7 則留言) (1 個反應) (1 位負責人)Go (316 個分叉)github user discovery
good first issuehelp wantedlow priority

倉庫指標

星標
 (5,517 顆星)
PR 合併指標
 (平均合併 10小時 48分鐘) (30 天內合併 3 個 PR)

描述

From https://github.com/mgechev/revive/pull/1353#issuecomment-2887129427:

I'm not sure we should test unexported functions. They are internals and a matter to be freely changed with the refactoring. Testing them makes code less flexible for refactoring and tests more fragile. In my current project, for example, we have this strongly discouraged (with some legacy exceptions).

To improve test structure and enforce better package boundaries, we should refactor our current test suite:

  1. Replace existing tests that target unexported functions with equivalent tests targeting exported functions. Ensure the functionality is still covered by indirectly testing through public APIs.
  2. Adopt _test package convention.
  3. Enable testpackage linter in the golangci-lint config.

貢獻者指南