testing-debugging/slides.org
author anand
Thu, 11 Nov 2010 00:03:57 +0530
changeset 472 fcdec2d28c9a
parent 403 9858ca9e3f93
child 487 cb3974daced5
permissions -rw-r--r--
Checklist OK for `The other kinds of plots`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     1
#+LaTeX_CLASS: beamer
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     2
#+LaTeX_CLASS_OPTIONS: [presentation]
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     3
#+BEAMER_FRAME_LEVEL: 1
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     4
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     5
#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     6
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     7
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     8
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     9
#+LaTeX_CLASS: beamer
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    10
#+LaTeX_CLASS_OPTIONS: [presentation]
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    11
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    12
#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    13
#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    14
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    15
#+LaTeX_HEADER: \usepackage{listings}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    16
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    17
#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    18
#+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{red},
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    19
#+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    20
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    21
#+TITLE:     Testing and debugging
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    22
#+AUTHOR:    FOSSEE
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    23
#+EMAIL:     
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    24
#+DATE:    
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    25
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    26
#+DESCRIPTION: 
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    27
#+KEYWORDS: 
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    28
#+LANGUAGE:  en
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    29
#+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    30
#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    31
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    32
* Outline 
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    33
  - What software Testing is? 
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    34
  - Learn to test simple functions for their functionality.
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    35
  - Learn how to automate tests. 
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    36
  -  Need for coding style and some of the standards followed by the Python Community.
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    37
  -  Handling Errors and Exceptions.
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    38
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    39
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    40
* gcd function
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    41
  - Create gcd.py file with:
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    42
#+begin_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    43
\begin{lstlisting}[language=python]
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    44
  def gcd(a, b):
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    45
        if a % b == 0: 
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    46
            return b
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    47
        return gcd(b, a%b)
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    48
\end{lstlisting}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    49
#+end_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    50
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    51
* Test for gcd.py
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    52
  - Edit gcd.py file
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    53
#+begin_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    54
\begin{lstlisting}[language=python]
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    55
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    56
  def gcd(a, b):
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    57
      if b == 0:
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    58
          return a
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    59
      return gcd(b, a%b)
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    60
  
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    61
  if __name__=='__main__':
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    62
      result = gcd(48, 64)
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    63
      if result != 16:
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    64
          print "Test failed"
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    65
      print "Test Passed"
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    66
\end{lstlisting}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    67
#+end_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    68
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    69
* Automating tests
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    70
#+begin_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    71
\begin{lstlisting}[language=python]
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    72
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    73
    if __name=__='__main__':
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    74
    for line in open('numbers.txt'):
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    75
        numbers = line.split()
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    76
        x = int(numbers[0])
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    77
        y = int(numbers[1])
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    78
        result = int(numbers[2])
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    79
        if gcd(x, y) != result:
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    80
            print "Failed gcd test
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    81
                          for", x, y
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    82
\end{lstlisting}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    83
#+end_LaTeX
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    84
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    85
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    86