/testing101

A sample code for the testing_101 lecture

Primary LanguagePython

  • Is 8 seconds considered a long time for a test to run?
    • Whatsapp analogy (8 seconds is a long time for a message to be sent right? That's the kind of feedback we're looking for)
    • Running tests locally vs CI
  • Simple example
    • pytest.mark.parametrized
    • with pytest.raises(Exception)
  • Frameworks testing utilities (pandas, asyncio, etc.)
  • Fragile e2e tests (example: "tests/test_histogram_reporter.py")
  • Single Responsibility Principle: Extract dependencies, use test doubles (example: "tests/test_histogram_reporter_srp.py")
    • This test didn't fail when refactoring from per-word to per-char.
    • Tests eliminate fear of change.
  • Patching make it easier to test (example: "tests/test_histogram_reporter_srp_patch.py")
  • Surprise from this morning! (example: "tests/test_histogram_reporter_codium.py")