Skip to content

Commit 96141d1

Browse files
committed
markdown source builds
Auto-generated via `{sandpaper}` Source : b93e579 Branch : main Author : Connor Aird <c.aird@ucl.ac.uk> Time : 2025-11-04 10:02:41 +0000 Message : Merge pull request #33 from UCL-ARC/32-add-refactoring-lesson Add refactoring lesson
1 parent 75b95ad commit 96141d1

7 files changed

Lines changed: 1359 additions & 109 deletions

File tree

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Introduction to Unit Testing"
2+
title: "What is a Unit Test"
33
teaching:
44
exercises:
55
---
@@ -8,20 +8,18 @@ exercises:
88

99
- What is unit testing?
1010
- Why do we need unit tests?
11-
- What makes src code difficult to unit test?
1211

1312
::::::::::::::::::::::::::::::::::::::::::::::::
1413

1514
::::::::::::::::::::::::::::::::::::: objectives
1615

1716
- Define the key aspects of a good unit test (isolated, testing minimal functionality, fast, etc).
1817
- Understand the key anatomy of a unit test in any language.
19-
- Explain the benefit of unit tests on top of integration/e2e tests.
18+
- Explain the benefit of unit tests on top of other types of tests.
2019
- Understand when to run unit tests.
2120

2221
::::::::::::::::::::::::::::::::::::::::::::::::
2322

24-
## What is unit testing?
2523

2624
Unit testing is a way of verifying the validity of a code base by testing its smallest individual components, or **units**.
2725

@@ -36,14 +34,14 @@ Several key aspects define a unit test. They should be...
3634

3735
::::::::::::::::::::::::::::::::::::: callout
3836

39-
#### Other forms of testing
37+
### Other forms of testing
4038

4139
There are other forms of testing, such as integration testing in which two or more units of a code base are tested to verify that they work together, or that they are correctly **integrated**.
4240
However, today we are focusing on unit tests as it is often the case that many of these larger tests are written using the same test tools and frameworks, hence we will make progress with both by starting with unit testing.
4341

4442
::::::::::::::::::::::::::::::::::::::::::::::::
4543

46-
### What does a unit test look like?
44+
## What does a unit test look like?
4745

4846
All unit tests tend to follow the same pattern of Given-When-Then.
4947

@@ -59,7 +57,7 @@ All unit tests tend to follow the same pattern of Given-When-Then.
5957

6058
::::::::::::::::::::::::::::::::::::: challenge
6159

62-
#### Challenge 1: Write a unit test in sudo code.
60+
### Challenge 1: Write a unit test in sudo code.
6361

6462
Assuming you have a function `reverse_array` which reverses the order of an allocated array. Write a unit test in pseudo code for `reverse_array` using the pattern above.
6563

@@ -83,7 +81,7 @@ for each element in `input_array`:
8381
:::::::::::::::::::::::::::::::::
8482
::::::::::::::::::::::::::::::::::::::::::
8583

86-
### When should unit tests be run?
84+
## When should unit tests be run?
8785

8886
A major benefit of unit tests is the ability to identify bugs at the earliest possible stage. Therefore, unit tests should be run frequently throughout the development process. Passing unit tests give you and your collaborators confidence that changes to your code aren't modifying the previously expected behaviour, so run your unit tests...
8987

@@ -96,7 +94,7 @@ A major benefit of unit tests is the ability to identify bugs at the earliest po
9694

9795
Basically, all the time.
9896

99-
### Do we really need unit tests?
97+
## Do we really need unit tests?
10098

10199
Yes!
102100

@@ -118,7 +116,7 @@ This is much clearer. We immediately have an idea of what could be going wrong a
118116

119117
::::::::::::::::::::::::::::::::::::: challenge
120118

121-
### Challenge 2: Unit test bad practices
119+
## Challenge 2: Unit test bad practices
122120

123121
Take a look at [1-into-to-unit-tests/challenge](https://github.com/UCL-ARC/fortran-unit-testing-exercises/tree/main/episodes/1-into-to-unit-tests/challenge) in the exercises repository.
124122

2-intro-to-fortran-unit-tests.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)