Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Commit

Permalink
add stuff on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed May 18, 2010
1 parent a14c899 commit 9da2a90
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
47 changes: 47 additions & 0 deletions go-packages.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,53 @@ \section{Testing packages}
Read the package doc!
\end{lbar}

The testing itself is carried out with \prog{gotest}.
The \prog{gotest} program run all the test functions, each
test function has the same signature:
\begin{lstlisting}
func TestXxx(t *testing.T) |\coderemark{Test<Capital>restOftheName}|
\end{lstlisting}

When writing test you will need to tell \prog{gotest} that a test has failed or was successful. A
successful test function just \func{return}s. When test fails you can signal this with the following
functions\cite{go_doc}. These are the most important ones:

\begin{lstlisting}
func (t *T) Fail()
\end{lstlisting}
Fail marks the Test function as having failed but continues execution.

\begin{lstlisting}
func (t *T) FailNow()
\end{lstlisting}
FailNow marks the Test function as having failed and stops its execution.
Execution will continue at the next Test.

\begin{lstlisting}
func (t *T) Errorf(format string, args ...interface\{\})
\end{lstlisting}
Errorf is equivalent to Logf() followed by Fail().

\begin{lstlisting}
func (t *T) Logf(format string, args ...interface\{\})
\end{lstlisting}
Log formats its arguments according to the format, analogous to Printf(),
and records the text in the error log.

\begin{lstlisting}
func (t *T) Fatal(args ...interface\{\})
\end{lstlisting}
Fatal is equivalent to Log() followed by FailNow().




\begin{lstlisting}
func (t *T) Failed() bool
\end{lstlisting}
Failed returns whether the Test function has failed.




\section{Useful packages}
Expand Down
8 changes: 7 additions & 1 deletion go.bib
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ @misc{csp

@misc{go_nuts,
author = "Go community",
title = "Go Nuts Mailing list",
title = "Go Nuts Mailing List",
howpublished = {Internet
\url{http://groups.google.com/group/golang-nuts}}
}
Expand All @@ -44,6 +44,12 @@ @misc{go_intro
\url{http://scienceblogs.com/goodmath/2009/11/googles_new_language_go.php}}
}

@misc{go_doc,
author = "Go Authors",
title = "Go Package Documentation",
howpublished = {Internet \url{http://golang/doc/pkg/}}
}

@misc{go_blog,
author = "Go authors",
title = "The Go Programming Language Blog",
Expand Down

0 comments on commit 9da2a90

Please sign in to comment.