PinnedHello, MediumThese are articles written for New Light Technologies. For other things I write, visit josiahulfers.com.Hello1 min readHello, MediumThese are articles written for New Light Technologies.For other things I write, visit josiahulfers.com.----
Published in New Light Technologies, Inc. (NLT·Mar 24, 2021Beyond assertLast time, we built a factorial function in a test-driven style using Python’s assert statement: def factorial(n): if n < 0: raise ValueError('Factorial of negative is undefined') return n * factorial(n-1) if n else 1 assert factorial(0) == 1 assert factorial(2) == 2 assert factorial(5) == 120 try…Testing3 min read
Published in New Light Technologies, Inc. (NLT·Mar 3, 2021Writing Tests FirstThere’s a best way to automate your tests: write them before you write the program. If you’ve heard “test-driven development,” that’s what it means, but if you’ve never seen such a thing before, it’s an unintuitive idea. How should you start? A basic example Here, we’ll develop a function that implements the factorial…Testing4 min read
Published in New Light Technologies, Inc. (NLT·Mar 3, 2021Basic Negative TestingIn part one, we started writing a factorial function in the test-driven style. We depend on the humble “assert” statement to run our tests and we ended with this: def factorial(n): return n * factorial(n-1) if n else 1 assert factorial(0) == 1 assert factorial(2) == 2 assert factorial(5) ==…Testing4 min read