

% add the PATH to retrieve cls and sty beamer styles files
\makeatletter
\providecommand*{\input@path}{}
\edef\input@path{{../../support/beamer/}\input@path}% prepend
\makeatother

% \documentclass{pharoslides}
% \documentclass[aspectratio=169]{pharoslides} % format 16/9
\documentclass[withvideo]{pharoslides} % format 16/9 + incrustation video

\graphicspath{{./figures/}{../}{../../support/beamer/imgs/}}

%Information to be included in the title page:
\title{Why Testing in a Nutshell}
\subtitle{}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\label{less}
\frametitle{Goal of the lecture}

\begin{itemize}
\item How can you trust that the changes did not destroy something?
\item What is my confidence in the system?
\item How do I write tests?
\item What is unit testing?
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\label{uniform}
\frametitle{Tests in a nutshell}

\begin{itemize}
\item Tests represent your trust in the system
\item Build them incrementally
\begin{itemize}
\item Do not need to focus on everything
\item When a new bug shows up, write a test
\end{itemize}

\item Even better write them before the code
\begin{itemize}
\item Act as your first client, better interface
\end{itemize}

\item Active documentation always in sync
\item It has a cost, but pay off is big
\begin{itemize}
\item writing them, maintain them
\end{itemize}

\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Testing Style}

\symbol{34}
The style here is to write a few lines of code, then a test that should run, or even better, to write a test that won't run, then write the code that will make it run.
\symbol{34}

\begin{itemize}
\item write unit tests that thoroughly test a single class
\item write tests as you develop (even before you implement)
\item write tests for every new piece of functionality
\end{itemize}

\textit{Developers should spend 25-50\% of their time developing tests.}
\end{frame}



\begin{frame}[fragile]

\frametitle{But I can’t cover everything!}

\begin{itemize}
\item Sure! Nobody can but
\item When someone discovers a defect in your code, first write a test that demonstrates the defect.
\item Then debug until the test succeeds.
\end{itemize}

	
\textit{Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead.} Martin Fowler
\end{frame}



\begin{frame}[fragile]

\frametitle{Unit Tests}

\begin{itemize}
\item Unit tests ensure that you get the specified behavior of the public interface of a class
\item Normally tests a single class
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{A Test}

A test

\begin{itemize}
\item Create a context 
\item Send a stimulus 
\item Check the results
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{A Test}

A test

\begin{itemize}
\item Create a context: Create an empty set
\item Send a stimulus: Add twice the same element
\item Check the results: Check that the set contains only one element
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Set TestCase}

\begin{listing}{}
TestCase subclass: # SetTestCase
    ...
\end{listing}

\begin{listing}{}
SetTestCase >> testAdd 
  | empty |
  empty := Set new.                      "Context"
  empty add: 5.                             "Stimulus"
  empty add: 5. 
  self assert: empty size = 1.        "Check"

SetTestCase run: #testAdd
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Good Tests}

\begin{itemize}
\item Repeatable
\item No human intervention
\item \symbol{34}self-described\symbol{34}
\item Change less often than the system
\item Tells a story
\end{itemize}
\end{frame}




% \setlength{\textwidth}{\originaltextwidth}
\setbeamertemplate{background canvas}{\insertBorderForHandout}

\begin{frame}[plain]

\begin{minipage}{\originaltextwidth}
\centering
\large


\vspace{2em}

A course by

\vspace{1em}

\hspace{-20px}\includegraphics[height=32px]{inriaLogo}\hspace{3em}\raisebox{7px}{and}\hspace{3em}\raisebox{-6px}{\includegraphics[height=30px]{logoutop}}

\vspace{2em}

in collaboration with

\vspace{1em}

\includegraphics[height=40px]{unisciellogo}\hskip 1.5em%
\raisebox{5px}{\includegraphics[height=30px]{unitlogo}}\hskip 2em%
\raisebox{8px}{\includegraphics[height=24px]{univLilleLogo}}\hskip 2em%
\raisebox{3px}{\includegraphics[height=29px]{logo-IMT}}\hskip 2em%
\raisebox{1px}{\includegraphics[height=32px]{minesDouaiLogo}}

\vspace{2.5em}

\includegraphics[width=50px]{by-nc-nd} \tiny \hskip 0.5em \raisebox{5px}{Inria 2016}

\medskip

\tiny
Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

\url{https://creativecommons.org/licenses/by-nc-nd/3.0/fr/} 

\end{minipage}
\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
