testing-debugging/slides.tex
author Amit Sethi
Fri, 12 Nov 2010 02:01:28 +0530
changeset 487 cb3974daced5
parent 403 9858ca9e3f93
permissions -rw-r--r--
Added questions and slides for testing and debugging
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
     1
% Created 2010-11-12 Fri 02:00
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     2
\documentclass[presentation]{beamer}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     5
\usepackage{fixltx2e}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     6
\usepackage{graphicx}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     7
\usepackage{longtable}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     8
\usepackage{float}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
     9
\usepackage{wrapfig}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    10
\usepackage{soul}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    11
\usepackage{t1enc}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    12
\usepackage{textcomp}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    13
\usepackage{marvosym}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    14
\usepackage{wasysym}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    15
\usepackage{latexsym}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    16
\usepackage{amssymb}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    17
\usepackage{hyperref}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    18
\tolerance=1000
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    19
\usepackage[english]{babel} \usepackage{ae,aecompl}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    20
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    21
\usepackage{listings}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    22
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    23
commentstyle=\color{red}\itshape, stringstyle=\color{red},
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    24
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    25
\providecommand{\alert}[1]{\textbf{#1}}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    26
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    27
\title{Testing and debugging}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    28
\author{FOSSEE}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    29
\date{}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    30
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    31
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    32
\begin{document}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    33
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    34
\maketitle
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    35
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    36
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    37
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    38
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    39
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    40
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    41
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    42
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    43
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    44
\begin{frame}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    45
\frametitle{Outline}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    46
\label{sec-1}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    47
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    48
\begin{itemize}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    49
\item What software Testing is?
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    50
\item Learn to test simple functions for their functionality.
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    51
\item Learn how to automate tests.
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    52
\item 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
    53
\item Handling Errors and Exceptions.
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    54
\end{itemize}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    55
\end{frame}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    56
\begin{frame}[fragile]
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    57
\frametitle{gcd function}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    58
\label{sec-2}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    59
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    60
\begin{itemize}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    61
\item Create gcd.py file with:
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    62
\end{itemize}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    63
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    64
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    65
def gcd(a, b):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    66
      if a % b == 0: 
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    67
          return b
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    68
      return gcd(b, a%b)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    69
\end{verbatim}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    70
\end{frame}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    71
\begin{frame}[fragile]
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    72
\frametitle{Test for gcd.py}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    73
\label{sec-3}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    74
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    75
\begin{itemize}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    76
\item Edit gcd.py file
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    77
\end{itemize}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    78
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    79
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    80
def gcd(a, b):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    81
    if b == 0:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    82
        return a
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    83
    return gcd(b, a%b)
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
    84
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    85
if __name__=='__main__':
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    86
    result = gcd(48, 64)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    87
    if result != 16:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    88
        print "Test failed"
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    89
    print "Test Passed"
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    90
\end{verbatim}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    91
\end{frame}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    92
\begin{frame}[fragile]
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    93
\frametitle{Automating tests}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    94
\label{sec-4}
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
    95
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    96
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    97
if __name=__='__main__':
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    98
for line in open('numbers.txt'):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
    99
    numbers = line.split()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   100
    x = int(numbers[0])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   101
    y = int(numbers[1])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   102
    result = int(numbers[2])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   103
    if gcd(x, y) != result:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   104
        print "Failed gcd test
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   105
                      for", x, y
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   106
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   107
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   108
\begin{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   109
\frametitle{Question 1}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   110
\label{sec-5}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   111
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   112
  For the same inputs as gcd write automated tests for LCM.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   113
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   114
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   115
\frametitle{Solution 1}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   116
\label{sec-6}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   117
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   118
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   119
def gcd(a, b):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   120
      if a % b == 0: 
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   121
          return b
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   122
      return gcd(b, a%b)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   123
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   124
 def lcm(a, b):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   125
      return (a * b) / gcd(a, b)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   126
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   127
  if __name__ == '__main__':
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   128
    for line in open('lcmtestcases.txt'):
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   129
      numbers = line.split()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   130
      x = int(numbers[0])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   131
      y = int(numbers[1])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   132
      result = int(numbers[2])
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   133
      if lcm(x, y) != result:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   134
          print "Failed lcm test for", x, y
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   135
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   136
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   137
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   138
\frametitle{Meaning full names}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   139
\label{sec-7}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   140
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   141
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   142
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   143
amount = 12.68
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   144
denom = 0.05
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   145
nCoins = round(amount / denom)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   146
rAmount = nCoins * denom
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   147
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   148
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   149
\begin{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   150
\frametitle{Code style}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   151
\label{sec-8}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   152
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   153
\begin{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   154
\item Four Space Indentation
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   155
\item 79 character limit on a line
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   156
\item Funtions should be seperated by 
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   157
   blank line
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   158
\item Use Docstring
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   159
\item White space around operators
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   160
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   161
\begin{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   162
\item l = 32 \% 4
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   163
\end{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   164
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   165
\end{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   166
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   167
\begin{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   168
\frametitle{Question 2}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   169
\label{sec-9}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   170
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   171
\begin{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   172
\item Give meaningful names to the variables in following
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   173
     code
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   174
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   175
\begin{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   176
\item c = a / b
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   177
\end{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   178
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   179
\end{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   180
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   181
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   182
\frametitle{Solution 2}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   183
\label{sec-10}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   184
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   185
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   186
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   187
quotient = dividend / divisor
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   188
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   189
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   190
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   191
\frametitle{Code Snippet}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   192
\label{sec-11}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   193
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   194
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   195
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   196
while True print 'Hello world'
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   197
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   198
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   199
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   200
\frametitle{Error}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   201
\label{sec-12}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   202
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   203
\begin{lstlisting}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   204
 while True print 'Hello world'
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   205
 \end{lstlisting}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   206
  \begin{lstlisting}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   207
  File "<stdin>", line 1, in ?
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   208
    while True print 'Hello world'
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   209
SyntaxError: invalid syntax
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   210
\end{lstlisting}
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   211
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   212
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   213
\frametitle{Code Snippet}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   214
\label{sec-13}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   215
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   216
\begin{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   217
a = raw_input("Enter a number")
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   218
try:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   219
      num = int(a)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   220
 except:
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   221
      print "Wrong input ..."
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   222
\end{verbatim}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   223
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   224
\begin{frame}[fragile]
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   225
\frametitle{Using idb}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   226
\label{sec-14}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   227
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   228
\small
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   229
\begin{lstlisting}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   230
In []: import mymodule
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   231
In []: mymodule.test()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   232
---------------------------------------------
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   233
NameError   Traceback (most recent call last)
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   234
<ipython console> in <module>()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   235
mymodule.py in test()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   236
      1 def test():
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   237
      2     total=1+1
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   238
----> 3     print spam
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   239
NameError: global name 'spam' is not defined
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   240
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   241
In []: %debug
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   242
> mymodule.py(2)test()
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   243
      0     print spam
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   244
ipdb> total
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   245
2
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   246
\end{lstlisting}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   247
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   248
\begin{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   249
\frametitle{Summary}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   250
\label{sec-15}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   251
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   252
\begin{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   253
\item Create simple tests for a function.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   254
\item Learn to Automate tests using many predefined test cases.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   255
\item Good coding standards.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   256
\item Difference between syntax error and exception.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   257
\item Handling exception using try and except.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   258
\item Using \%debug for debugging on ipython.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   259
\end{itemize}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   260
\end{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   261
\begin{frame}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   262
\frametitle{Thank you!}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   263
\label{sec-16}
403
9858ca9e3f93 Adding testing and debugging slides
Amit Sethi
parents: 401
diff changeset
   264
487
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   265
  \begin{block}{}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   266
  \begin{center}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   267
  This spoken tutorial has been produced by the
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   268
  \textcolor{blue}{FOSSEE} team, which is funded by the 
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   269
  \end{center}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   270
  \begin{center}
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   271
    \textcolor{blue}{National Mission on Education through \\
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   272
      Information \& Communication Technology \\ 
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   273
      MHRD, Govt. of India}.
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   274
  \end{center}  
cb3974daced5 Added questions and slides for testing and debugging
Amit Sethi
parents: 403
diff changeset
   275
  \end{block}
401
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
   276
\end{frame}
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
   277
abf092be95ef Adding testing and debugging files
Amit Sethi
parents:
diff changeset
   278
\end{document}