-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-why-do-unit-testing.Rmd
44 lines (36 loc) · 1.59 KB
/
01-why-do-unit-testing.Rmd
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
---
title: "Why do unit testing?"
author: "Kamil Foltyński"
date: "11/04/2019"
output:
html_document:
fig_caption: yes
keep_md: no
toc: yes
toc_float:
collapsed: no
smooth_scroll: yes
runtime: shiny
---
```{r, echo=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = ">")
```
# Why do unit testing?
1. Existing unit tests ensures that implemented changes, improvements, fixes
doen't break anything that already exists and works
* Fixing specific feature may result in breaking some other functionality
2. Saves time and reduces costs
* no need/reduced need for manual testing of code results
3. Makes refactoring much easier and faster and reduces risk
* sometimes some old feature needs to be redesigned and changing already working and tested code is risky,
but when unit test are written it's much easier because we know what to expect,
e.g. sepcific inputs, outputs or variable types
4. With unit tests we get bonus: _documentation_ :)
* _documentation_, but not literally - what I mean is that when we look at unit tests code we can easily learn
how some function or whole feature works, what input it accepts, what is the output, what _edge cases_ we can expect,
what we need to be careful of, etc.
5. Debug faster
* Well unit tested code is a boost in debugging - when last commit breaks test(s) it means last code change should be investigated first. Without unit tests we might not even know that something was broken before last commit and
it is just coincidence we noticed that now
# Sources
* https://dzone.com/articles/top-8-benefits-of-unit-testing