- Test with simple cases, using hard coded solutions
- @my\_sum([1,2,3]) == 6@
- Test special or boundary cases
- @my\_sum([]) == 0@
- Test that meaningful error messages are raised upon corrupt input
- @my\_sum(['1',])@
- --> @TypeError: unsupported operand type(s) for +: 'int' and 'str'@
Probabilistic code
- Use toy examples as validation
- Consider fixing the seed for your pseudo random number generator
- use mock up software that behaves like the hardware should
- (any creative ideas welcome)
<[center] <<<images/define_test.pdf, scale="0.25"></images/define_test.pdf,>>>
\hspace{10cm}
function @my\_sum@ should return the sum of a list.
[center]>
<[center] <<<images/simplest_version.pdf, scale="0.25"></images/simplest_version.pdf,>>>
\hspace{10cm}
<[code][style=basic,] def my_sum(my_list):
""" Compute sum of list elements. """ answer = 0 for item in my_list: answer = answer + item return answer
[code]>
[center]>
<[center] <<<images/ensure_test.pdf, scale="0.25"></images/ensure_test.pdf,>>>
\hspace{10cm}
<[code][style=basic,] >>> my_sum(\[1,2,3\]) 6 [code]>
[center]>
<[center] <<<images/better_version.pdf, scale="0.25"></images/better_version.pdf,>>>
\hspace{10cm}
<[code][style=basic,] def my_sum(my_list):
""" Compute sum of list elements. """ return sum(my_list)
[code]>
[center]>
<[figure][ht]
<<<images/central.pdf, scale="0.25"></images/central.pdf,>>>
[figure]>
- repository is located on a server
- Developers must connect to this server
<[figure]
<<<images/repository.pdf, scale="0.25"></images/repository.pdf,>>>
[figure]>
- Many different systems available
- We will use the de-facto standard:
<<<images/subversion_logo.pdf, scale="0.3"></images/subversion_logo.pdf,>>>
[figure]>
- Look at tools to support the agile workflow
- Better testing with Unit Tests
- Keeping track of changes and collaborating with Version Control
- Additional techniques
- Split feature into units
- Use the agile workflow
- Tests drive the development
- Keep the iterations small
<[figure]
<<<images/agile_reloaded.pdf, scale="0.25"></images/agile_reloaded.pdf,>>>
[figure]> sic Version Control Workflow ====
<[figure]
<<<images/vc_workflow.pdf, scale="0.25"></images/vc_workflow.pdf,>>> [figure]>
- We will be using centralised version control, note there exists also decentralised version control
- Again, it might take a while to get used to the idea, but it will pay off rapidly.
- Questions
- independent (of each other, and of user input)
- repeatable (i.e. deterministic)
- self-contained
- All unit tests are collected into a test suite
- Execute the entire test suite with a single command
- Can be used to provide reports and statistics