https://github.com/danesherbs/tdd-skeleton

Skeleton for TDD exercise

https://github.com/danesherbs/tdd-skeleton

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (3.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Skeleton for TDD exercise

Basic Info
  • Host: GitHub
  • Owner: danesherbs
  • License: mit
  • Default Branch: main
  • Size: 26.4 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 5 years ago · Last pushed over 5 years ago
Metadata Files
Readme License

README.md

The TDD loop: Red, Green, Refactor.

  • Write a failing test.
  • Write the minimal amount of code for the test to pass.
  • Refactor (if needed).

Advantages

  • Tests give confidence when refactoring since they act as a safety harness.
  • Brittle tests are quickly found in the refactoring step of the TDD loop.
  • Following the TDD loop results in an emergent design, which is often preferred over a plan-then-implement design.

Test structure

Use the Given-When-Then structure

Improves the readability of test cases, especially when there are many.

python def test_dog_makes_woof_sound(): assertTrue("woof" in Dog().bark().sounds())

✅ ```python def testdogmakeswoofsound(): # Given dog = Dog()

# When dog.bark()

# Then assertTrue("woof" in dog.sounds()) ```

Test one behaviour at a time

Allows you to test behaviours independently of one another.

Makes debugging easier when test cases are failing.

❌ ```python def testdogmakes_sounds(): # Given dog = Dog()

# When dog.bark() dog.sniff()

# Then assertTrue("woof" in dog.sounds()) assertTrue("sniff" in dog.sounds()) ```

✅ ```python def testdogmakeswoofsound(): # Given dog = Dog()

# When dog.bark()

# Then assertTrue("woof" in dog.sounds())

def testdogmakessniffsound(): # Given dog = Dog()

# When dog.sniff()

# Then assertTrue("sniff" in dog.sounds()) ```

Keep tests independent

Independent tests are easier to reason about.

❌ ```python

dog = Dog()

def testdogmakeswoofsound(): # When dog.bark()

# Then assertEqual(dog.sounds(), ["woof"])

def testdogmakessniffsound(): # When dog.sniff()

# Then assertEqual(dog.sounds(), ["sniff"]) # Failure: expected ["sniff"] but got ["woof", "sniff"] ```

✅ ```python def testdogmakeswoofsound(): # Given dog = Dog()

# When dog.bark()

# Then assertEqual(dog.sounds(), ["woof"])

def testdogmakessniffsound(): # Given dog = Dog()

# When dog.sniff()

# Then assertEqual(dog.sounds(), ["sniff"]) ```

Owner

  • Name: Dane
  • Login: danesherbs
  • Kind: user
  • Location: Melbourne, Australia

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 22
  • Total Committers: 1
  • Avg Commits per committer: 22.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Dane d****s 22

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels