Skip to content

[Testing] Organizing test utilities package(s) #609

@bryanchriswhite

Description

@bryanchriswhite

Objective

Agree on a convention which we can document that establishes where to put common test code for reuse between packages.

Origin Document

image

Goals

  • Agree on a conventional place to organize test utilities packages (e.g. pocket/internal/testing)
  • Support de-duplication of test code across packages (i.e. test util pkgs are importable )
  • Ensure test packages are excluded from non-test builds (e.g. using build constraints: //go:build test)

Deliverable

Non-goals / Non-deliverables

  • Identifying additional duplication
  • Refactoring unrelated test code

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • Ensure test util package members are not present in symbol table of non-test builds:

    1. go build -o ./pokt-node ./app/pocket
    2. nm ./pokt-node | grep prepareDNSResolverMock should print nothing
      If prepareDNSResolverMock was included in the build, it will be listed in the symbol table which we can print with nm. Double-check the function names match, a typo could result in a false positive. Additionally, one can build a test binary (go test -c -o <output bin path> [-run <test func name>] <pkg>) on a test/pig which is known to import a test util function and ensure that it is present in the symbol table, as a control.
  • All tests: make test_all

  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md


Creator: @bryanchriswhite
Co-Owners: @deblasis

Metadata

Metadata

Labels

code healthNice to have code improvementtestingDefining, adding, automating or modifying tests

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions