forked from rachelslaybaugh/python-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-basics.html
More file actions
82 lines (82 loc) · 4.57 KB
/
01-basics.html
File metadata and controls
82 lines (82 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: Testing</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">Testing</h1></a>
<h2 class="subtitle">Basics of Testing</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
<li>Understand the place of testing in a scientific workflow.</li>
<li>Understand that testing has many forms.</li>
</ul>
</div>
</section>
<p>The first step toward getting the right answers from our programs is to assume that mistakes <em>will</em> happen and to guard against them. This is called <strong>defensive programming</strong> and the most common way to do it is to add alarms and tests into our code so that it checks itself.</p>
<p><strong>Testing</strong> should be a seamless part of scientific software development process. This is analogous to experiment design in the experimental science world:</p>
<ul>
<li>At the beginning of a new project, tests can be used to help guide the overall architecture of the project.</li>
<li>The act of writing tests can help clarify how the software should be perform when you are done.</li>
<li>In fact, starting to write the tests <em>before</em> you even write the software might be advisable. (Such a practice is called <em>test-driven development</em>, which we will discuss in greater detail <a href="09-tdd.html">later in the lesson</a>.)</li>
</ul>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>What Kinds of Tests Exist</h2>
</div>
<div class="panel-body">
<p>There are many ways to test software, such as:</p>
<ul>
<li>Assertions</li>
<li>Exceptions</li>
<li>Unit Tests</li>
<li>Regresson Tests</li>
<li>Integration Tests</li>
</ul>
</div>
</aside>
<p><em>Exceptions and Assertions</em>: While writing code, <code>exceptions</code> and <code>assertions</code> can be added to sound an alarm as runtime problems come up. These kinds of tests, are embedded in the software iteself and handle, as their name implies, exceptional cases rather than the norm.</p>
<p><em>Unit Tests</em>: Unit tests investigate the behavior of units of code (such as functions, classes, or data structures). By validating each software unit across the valid range of its input and output parameters, tracking down unexpected behavior that may appear when the units are combined is made vastly simpler.</p>
<p><em>Regression Tests</em>: Regression tests defend against new bugs, or regressions, which might appear due to new software and updates.</p>
<p><em>Integration Tests</em>: Integration tests check that various pieces of the software work together as expected.</p>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
</body>
</html>