Advanced Testing

#Talks

#Advanced Testing with Go by Mitchell Hashimoto

Notes:

  • golden_test.go Testing with golden files and updating them (while using testdata).
    # udpate
    > go test -update
    
  • testing.go Having testing.go or testing_.go (or file_testing.go) to provide Testing API.
  • network_testing.go server listner fixture (see https://github.com/hashicorp/go-plugin ).
  • subprocessing_test.go testing subprocesses with Entrypoint

#Testing Techniques by Andrew Gerrand

Notes_:

  • Table-driven Tests

#Go Testing By Example by Russ Cox

  1. Make it easy to add new test cases.
  2. Use test coverage to find untested code.
  3. Coverage is no substitute for thought.
  4. Write exhaustive tests.
  5. Separate test cases from test logic.
  6. Look for special cases.
  7. If you didn’t add a test, you didn’t fix the bug.
  8. Not everything fits in a table.
  9. Test cases can be in testdata files.
  10. Compare against other implementations.
  11. Make test failures readable.
  12. If the answer can change, write code to update them.
  13. Use txtar for multi-file test cases.
  14. Annotate existing formats to create testing mini-languages.
  15. Write parsers and printers to simplify tests.
  16. Code quality is limited by test quality.
  17. Scripts make good tests.
  18. Try rsc.io/script for your own script-based test cases.
  19. Improve your tests over time.
  20. Aim for continuous deployment.

#Testing Patterns

A test is not a unit test if:

  • It talks to the database
  • It communicates across the network
  • It touches the file system
  • It can’t run at the same time as any of your other unit tests
  • You have to do special things to your environment to run it.

#Reading