Skip to content

Latest commit

 

History

History
174 lines (104 loc) · 3.07 KB

unused.wiki

File metadata and controls

174 lines (104 loc) · 3.07 KB

Table of Contents

Unit Testing

How to Test ?

  • 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'@

Stuff That's Harder to Test

Probabilistic code

  • Use toy examples as validation
  • Consider fixing the seed for your pseudo random number generator
Hardware
  • use mock up software that behaves like the hardware should
Plots
  • (any creative ideas welcome)

Example

<[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]>

Agile Methods

Example

<[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]>

Example

<[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]>

Example

<[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]>

Version Control

Where the Versions are Stored?

<[figure][ht]

    <<&lt;images/central.pdf, scale=&quot;0.25&quot;&gt;&lt;/images/central.pdf,&gt;>>

[figure]>

  • repository is located on a server
  • Developers must connect to this server

Contents of the Repository

<[figure]

    <<&lt;images/repository.pdf, scale=&quot;0.25&quot;&gt;&lt;/images/repository.pdf,&gt;>>

[figure]>

What Will We Use ?

  • Many different systems available
  • We will use the de-facto standard:
<[figure][ht]

    <<&lt;images/subversion_logo.pdf, scale=&quot;0.3&quot;&gt;&lt;/images/subversion_logo.pdf,&gt;>>

[figure]>

Whats Next

  • Look at tools to support the agile workflow
  • Better testing with Unit Tests
  • Keeping track of changes and collaborating with Version Control
  • Additional techniques

Introducing New Features

  • Split feature into units
  • Use the agile workflow
  • Tests drive the development
  • Keep the iterations small

The Basic Agile Workflow - Reloaded

<[figure]

    <<&lt;images/agile_reloaded.pdf, scale=&quot;0.25&quot;&gt;&lt;/images/agile_reloaded.pdf,&gt;>>

[figure]> sic Version Control Workflow ====

<[figure]

    <<&lt;images/vc_workflow.pdf, scale=&quot;0.25&quot;&gt;&lt;/images/vc_workflow.pdf,&gt;>>
    [figure]>

Some Last Thoughts

  • 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

What Makes a Good Test?

  • independent (of each other, and of user input)
  • repeatable (i.e. deterministic)
  • self-contained

Test Suits

  • 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