Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes the tests to not run the demo program #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xxxserxxx
Copy link

The test suite was mostly testing the demo program; one test (TestUnregisteredRootCommand) only tested demo program behavior, without executing any checks on the core library.

This PR replaces all command-executions in tests with programmatic equivalents; it also removes the test for the demo program -- if that program were tested, it'd be best done in demo/cmd_test.go, not in the library.

Benchmarks show an improvement from 8.6 seconds per run to 500 milliseconds per run, or a 17x speed improvement. More importantly, the tests are more directly testing the library, not the demo program. Improvements are still possible; these tests are functional tests rather than unit tests.

Benchmark for pre-PR:

hyperfine 'go test . ; go clean -testcache' 
Benchmark 1: go test . ; go clean -testcache
  Time (mean ± σ):      8.601 s ±  2.788 s    [User: 10.870 s, System: 5.040 s]
  Range (min … max):    5.799 s … 13.011 s    10 runs

Post-PR:

10220(tests)⚡ » hyperfine 'go test . ; go clean -testcache' 
Benchmark 1: go test . ; go clean -testcache
  Time (mean ± σ):     503.5 ms ± 160.1 ms    [User: 849.9 ms, System: 325.8 ms]
  Range (min … max):   353.0 ms … 901.0 ms    10 runs

program, more than it was testing the library, and it was slow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant