Difference between revisions of "Writing unit tests"

From Simson Garfinkel
Jump to navigationJump to search
m
m
Line 3: Line 3:
== Key Concepts ==
== Key Concepts ==
* Smallest testable unit
* Smallest testable unit
* Test Cases
* Test Discovery
* Test Discovery
* Test Coverage
* Test Coverage
* Test on commit
* Test Driven Development / [http://pythontesting.net/agile/test-first-programming/ Test First Programming] / Test First Development
* Test cases
* Turning bugs into test cases
* Turning bugs into test cases
* Integration Testing / Test on commit





Revision as of 09:06, 25 April 2018

Information on writing unit tests, from the Internet:

Key Concepts

  • Smallest testable unit
  • Test Cases
  • Test Discovery
  • Test Coverage
  • Test Driven Development / Test First Programming / Test First Development
  • Turning bugs into test cases
  • Integration Testing / Test on commit


General Guidance

  • When you write a function, immediately write the test. (Or, better, write the test before you write the function).
  • If function A creates a data object and then calls function B, which does something to the data object and then calls function C, it may be difficult to generate a test for each function. This may indicate that you should refactor your program. For example, you may wish to create a new class, AA, which has different methods for different data functions. You can then write tests for each of these methods.

Testing Python with py.test


Other collateral