403
|
1 |
% Created 2010-11-07 Sun 18:57
|
|
2 |
\documentclass[presentation]{beamer}
|
401
|
3 |
\usepackage[latin1]{inputenc}
|
|
4 |
\usepackage[T1]{fontenc}
|
403
|
5 |
\usepackage{fixltx2e}
|
|
6 |
\usepackage{graphicx}
|
|
7 |
\usepackage{longtable}
|
|
8 |
\usepackage{float}
|
|
9 |
\usepackage{wrapfig}
|
|
10 |
\usepackage{soul}
|
|
11 |
\usepackage{t1enc}
|
|
12 |
\usepackage{textcomp}
|
|
13 |
\usepackage{marvosym}
|
|
14 |
\usepackage{wasysym}
|
|
15 |
\usepackage{latexsym}
|
|
16 |
\usepackage{amssymb}
|
|
17 |
\usepackage{hyperref}
|
|
18 |
\tolerance=1000
|
|
19 |
\usepackage[english]{babel} \usepackage{ae,aecompl}
|
|
20 |
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
|
|
21 |
\usepackage{listings}
|
|
22 |
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
|
|
23 |
commentstyle=\color{red}\itshape, stringstyle=\color{red},
|
|
24 |
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
|
|
25 |
\providecommand{\alert}[1]{\textbf{#1}}
|
401
|
26 |
|
403
|
27 |
\title{Testing and debugging}
|
|
28 |
\author{FOSSEE}
|
401
|
29 |
\date{}
|
|
30 |
|
403
|
31 |
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
|
401
|
32 |
\begin{document}
|
|
33 |
|
403
|
34 |
\maketitle
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
401
|
44 |
\begin{frame}
|
403
|
45 |
\frametitle{Outline}
|
|
46 |
\label{sec-1}
|
|
47 |
|
|
48 |
\begin{itemize}
|
|
49 |
\item What software Testing is?
|
|
50 |
\item Learn to test simple functions for their functionality.
|
|
51 |
\item Learn how to automate tests.
|
|
52 |
\item Need for coding style and some of the standards followed by the Python Community.
|
|
53 |
\item Handling Errors and Exceptions.
|
|
54 |
\end{itemize}
|
401
|
55 |
\end{frame}
|
|
56 |
\begin{frame}[fragile]
|
403
|
57 |
\frametitle{gcd function}
|
|
58 |
\label{sec-2}
|
|
59 |
|
|
60 |
\begin{itemize}
|
|
61 |
\item Create gcd.py file with:
|
|
62 |
\end{itemize}
|
401
|
63 |
|
403
|
64 |
\begin{lstlisting}[language=python]
|
|
65 |
def gcd(a, b):
|
|
66 |
if a % b == 0:
|
|
67 |
return b
|
|
68 |
return gcd(b, a%b)
|
|
69 |
\end{lstlisting}
|
|
70 |
\end{frame}
|
401
|
71 |
\begin{frame}[fragile]
|
403
|
72 |
\frametitle{Test for gcd.py}
|
|
73 |
\label{sec-3}
|
|
74 |
|
|
75 |
\begin{itemize}
|
|
76 |
\item Edit gcd.py file
|
|
77 |
\end{itemize}
|
|
78 |
|
|
79 |
\begin{lstlisting}[language=python]
|
401
|
80 |
|
403
|
81 |
def gcd(a, b):
|
|
82 |
if b == 0:
|
|
83 |
return a
|
|
84 |
return gcd(b, a%b)
|
|
85 |
|
|
86 |
if __name__=='__main__':
|
|
87 |
result = gcd(48, 64)
|
|
88 |
if result != 16:
|
|
89 |
print "Test failed"
|
|
90 |
print "Test Passed"
|
|
91 |
\end{lstlisting}
|
|
92 |
\end{frame}
|
|
93 |
\begin{frame}[fragile]
|
|
94 |
\frametitle{Automating tests}
|
|
95 |
\label{sec-4}
|
|
96 |
|
|
97 |
\begin{lstlisting}[language=python]
|
|
98 |
|
|
99 |
if __name=__='__main__':
|
|
100 |
for line in open('numbers.txt'):
|
|
101 |
numbers = line.split()
|
|
102 |
x = int(numbers[1])
|
|
103 |
y = int(numbers[2])
|
|
104 |
result = int(numbers[3])
|
|
105 |
if gcd(x, y) != result:
|
|
106 |
print "Failed gcd test
|
|
107 |
for", x, y
|
|
108 |
\end{lstlisting}
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
$^{1}$ FOOTNOTE DEFINITION NOT FOUND: 0
|
|
114 |
|
|
115 |
$^{2}$ FOOTNOTE DEFINITION NOT FOUND: 1
|
|
116 |
|
|
117 |
$^{3}$ FOOTNOTE DEFINITION NOT FOUND: 2
|
401
|
118 |
\end{frame}
|
|
119 |
|
|
120 |
\end{document}
|