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