summaryrefslogtreecommitdiff
path: root/TDD
diff options
context:
space:
mode:
Diffstat (limited to 'TDD')
-rw-r--r--TDD/getting_started_with_tdd/tdd1.tex69
-rwxr-xr-xTDD/getting_started_with_tdd/tdd1_script.rst8
-rw-r--r--TDD/using_python_framework_for_tdd/tdd2.tex20
-rwxr-xr-xTDD/using_python_framework_for_tdd/tdd2_script.rst51
4 files changed, 117 insertions, 31 deletions
diff --git a/TDD/getting_started_with_tdd/tdd1.tex b/TDD/getting_started_with_tdd/tdd1.tex
index f056ce5..042c5c4 100644
--- a/TDD/getting_started_with_tdd/tdd1.tex
+++ b/TDD/getting_started_with_tdd/tdd1.tex
@@ -254,7 +254,7 @@ def fibonacci(n):
\begin{itemize}
-\item Undestand the basic steps involved in Test driven development.
+\item Understand the basic steps involved in Test driven development.
\item Design a TDD approach for a given \texttt{fibonacci} function.
\end{itemize}
@@ -267,20 +267,75 @@ def fibonacci(n):
\begin{enumerate}
-\item ?
+\item Design a TDD approach for a \texttt{factorial} function.
\vspace{8pt}
-\item ?
+\item Design a TDD approach for an \texttt{armstrong} function.
\end{enumerate}
\end{frame}
-\begin{frame}
+
+\begin{frame}[fragile]
\frametitle{Solutions}
\label{sec-10}
+\begin{enumerate}
+\vspace{15pt}
+\item
+{\tiny
+\begin{lstlisting}
+def factorial(n):
+ if n < 0 :
+ return None;
+ if n == 1:
+ return 1
+ else:
+ return n * factorial (n - 1)
+if __name__ == '__main__':
+ f = factorial(3)
+ if f != 6 :
+ print 'Test Failed...'
+ exit (1)
+ f = factorial(-5)
+ if f != None :
+ print 'Test Failed...'
+ exit (1)
+ print 'All tests passed...'
+\end{lstlisting}
+}
+\end{enumerate}
+\end{frame}
-
+\begin{frame}[fragile]
+\frametitle{Solutions}
+\label{sec-10}
\begin{enumerate}
-\item
\vspace{15pt}
-\item
+\item
+{\tiny
+\begin{lstlisting}
+def armstrong(n):
+ sum = 0
+ temp = 0
+ remainder = 0
+ temp = n
+ while temp > 0 :
+ remainder = temp % 10
+ sum = sum + remainder * remainder * remainder
+ temp = temp / 10
+ if n == sum:
+ return True
+ else:
+ return False
+if __name__ == '__main__':
+ is_armstrong = armstrong(0)
+ if is_armstrong != True:
+ print "this is not armstrong"
+ exit(1)
+ is_armstrong = armstrong(371)
+ if is_armstrong == True:
+ print "this is armstrong"
+ exit(1)
+ print 'All tests passed...'
+\end{lstlisting}
+}
\end{enumerate}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/TDD/getting_started_with_tdd/tdd1_script.rst b/TDD/getting_started_with_tdd/tdd1_script.rst
index 9da1613..88c1227 100755
--- a/TDD/getting_started_with_tdd/tdd1_script.rst
+++ b/TDD/getting_started_with_tdd/tdd1_script.rst
@@ -175,9 +175,9 @@ This brings us to the end of the tutorial.In this tutorial,
.. R14
Here are some self assessment questions for you to solve
- 1.
- 2.
+ 1. Design a TDD approach for a factorial function.
+ 2. Design a TDD approach for an armstrong function.
.. L14
@@ -186,9 +186,9 @@ Here are some self assessment questions for you to solve
.. R15
And the answers are,
- 1.
+ 1. {{{ show answer slide-1 }}}
- 2.
+ 2. {{{ show answer slide-2 }}}
.. L15
diff --git a/TDD/using_python_framework_for_tdd/tdd2.tex b/TDD/using_python_framework_for_tdd/tdd2.tex
index 561f4a2..1aa409f 100644
--- a/TDD/using_python_framework_for_tdd/tdd2.tex
+++ b/TDD/using_python_framework_for_tdd/tdd2.tex
@@ -294,7 +294,7 @@ if __name__ == '__main__':
\item Allows us to pick and choose which tests to run
\item Helps output the test-results and aggregate them in various
formats
- \item Not part of the Python distribution itself
+ \item Not part of the Python distribution itself \footnote{$http://packages.python.org/distribute/easy$\textunderscore$install.html$}
\begin{lstlisting}
$ easy_install nose
\end{lstlisting} %$
@@ -328,9 +328,19 @@ $ nosetests
\begin{enumerate}
-\item ?
+\item An underlying assumption of TDD is that you have a testing framework available to you.\\
+ \begin{enumerate}
+ \item True
+ \item False
+ \end{enumerate}
\vspace{8pt}
-\item ?
+\item Test-Driven Development is an advanced technique of using automated \_\_\_\_\_\_\_\_\_ tests to drive the design of software and force deoupling of dependecies.\\
+ \begin{enumerate}
+ \item Incremental
+ \item Unit
+ \item Programming
+ \item Object
+ \end{enumerate}
\end{enumerate}
\end{frame}
\begin{frame}
@@ -339,9 +349,9 @@ $ nosetests
\begin{enumerate}
-\item
+\item True
\vspace{15pt}
-\item
+\item Unit
\end{enumerate}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/TDD/using_python_framework_for_tdd/tdd2_script.rst b/TDD/using_python_framework_for_tdd/tdd2_script.rst
index d90c5eb..b775b01 100755
--- a/TDD/using_python_framework_for_tdd/tdd2_script.rst
+++ b/TDD/using_python_framework_for_tdd/tdd2_script.rst
@@ -155,7 +155,7 @@ tests into collections and improves reporting.
.. L11
-{{{ Switch to slide-11, Unittest }}}
+{{{ Switch to slide-11(stay for 5 seconds) and switch to slide 12 }}}
.. R12
@@ -170,7 +170,7 @@ files too.
.. L12
-{{{ Show slide13, unittesting fibonacci.py }}}
+{{{ Show slide13(stay for 3 seconds) and switch to slide14 }}}
.. R13
@@ -183,10 +183,31 @@ and closes ``fibonacci_testcases.dat`` file.
.. L13
-{{{ Show slide13(stay for 3 seconds) and switch to slide14 }}}
+{{{ Show slide 15, test_fibonacci.py }}}
+
+
+.. R14
+
+Individual unittests and doctests may not be fiseable to use when
+multiple files are to be tested. For this purpose we have a python
+utility called Nose. Nose test aggregates unittests and doctests. Nose
+test utility can be installed by using the following command
+``$ easy_install nose``. It can be run by issuing the command ``$ nosetests``
+in the root level of the directory containing all your python files to be tested.
+
+.. L14
+
+{{{ Show slide15(for 5 seconds), nose tests }}}
+
+{{{ Follow the commands in terminal. }}}
+::
+
+ $ easy_install nose
+ $ nosetests
+
+.. R15
-.. R23
This brings us to the end of the tutorial.In this tutorial,
we have learnt to,
@@ -195,38 +216,38 @@ we have learnt to,
#. Design a Test driven approach for a given ``fibonacci`` function.
-.. L23
+.. L15
-{{{ switch to slide-13,Summary }}}
+{{{ switch to slide-17,Summary }}}
-.. R14
+.. R16
Here are some self assessment questions for you to solve
1.
2.
-.. L14
+.. L16
-{{{ switch to slide-14, Evaluation }}}
+{{{ switch to slide-18, Evaluation }}}
-.. R15
+.. R17
And the answers are,
1.
2.
-.. L15
+.. L17
-{{{ switch to slide-15 ,Solutions}}}
+{{{ switch to slide-19 ,Solutions}}}
-.. R16
+.. R18
Hope you have enjoyed this tutorial and found it useful.
Thank you!
-.. L16
+.. L18
-{{{ Switch to slide-16, Thank you}}}
+{{{ Switch to slide-20, Thank you}}}