Skip to content

Commit

Permalink
Merge pull request #17 from esciencecenter-digital-skills/dev_sofware…
Browse files Browse the repository at this point in the history
…_testing_module

Adding Testing Module
  • Loading branch information
Cmurilochem authored Apr 9, 2024
2 parents 7cbda99 + b2c88ae commit 86e6dcb
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 12 deletions.
13 changes: 1 addition & 12 deletions modules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,4 @@ thumbnail: "nlesc-dummy.png"
visibility: visible
---

:::Chapter{headline="Software testing" widemd=1}
## Testing

This module is still under development

:::

:::Chapter{headline="CI/CD" widemd=1}
## CI/CD

This module is still under development
:::
# Software testing
36 changes: 36 additions & 0 deletions modules/testing/exercise1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Exercise 1

Choose an alternative that correctly answers the following questions:

**1.1 What is software testing?**

a) A method for evaluating a software's compatibility with different operating systems.

b) The process of releasing updates and patches for software.

c) The process of verifying and validating that a software meets the required specifications and works as intended.

d) A step in the software lifecycle focused on community engagement and feedback.

e) The practice of documenting software functionalities.

---

**1.2 Why is software testing important?**

a) To build and maintain the community's trust by demonstrating commitment to quality.

b) To identify and fix bugs, ensure the software meets required standards, and assess its reliability and reproducibility.

c) To design the software's user interface and graphics.

d) To accelerate the overall software development process.

e) To facilitate easier collaboration among developers.

---

<small> **answers:**
1.1 c)
1.2 The most obvious answer is b), but in fact all answers except c) are correct
</small>
60 changes: 60 additions & 0 deletions modules/testing/exercise2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Exercise 2

## Instructions

- Match the items in Column A with their corresponding items in Column B.
- Write the letter of the correct match next to each item in Column A.
- Have fun and learn!

---

### Column A

1. Smoke Test

2. Unit Test

3. Integration Test

4. System Test

5. Regression Test

---

### Column B

A. Style of testing that focuses on retesting after changes are made. The results of tests after the changes are compared to the results before, and errors are raised if these are different. The purpose of this test is to ensure that changes (enhancements or defect fixes) to the software have not adversely affected it.

B. A level of the software testing process where the complete, integrated system is tested. The purpose of this test is to evaluate whether the system as a whole gives the correct outputs for given inputs.

C. Very brief initial checks that ensure the basic units required to run the software can be initialized. If these fail there is no point proceeding to additional levels of testing until they are fixed.

D. A level of software testing where individual units are combined and tested as a group. The purpose of this level of testing is to expose faults in the interaction between integrated units.

E. A level of the software testing process where individual units of a software are tested. The purpose is to ensure that each unit of the software works as expected.

---

## Answers

(Leave this blank for now, you can fill in the answers after completing the activity)

1.

2.

3.

4.

5.

---

## Hint

Here’s an analogy: during the process of manufacturing a ballpoint pen, the cap, the body, the tail, the ink cartridge and the ballpoint are produced separately and unit tested separately. When two or more units are ready, they are assembled and integration testing is performed, for example a test to check the cap fits on the body. When the complete pen is integrated, system testing is performed to check it can be used to write like any pen should.

<small> correct answers: 1.C., 2.E., 3.D., 4.B., and 5.A </small>

21 changes: 21 additions & 0 deletions modules/testing/exercise3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Exercise 3

## Scenario

You are part of a research team working on a complex simulation software that models climate change. The software is developed collaboratively by a diverse group of scientists, each contributing to different modules (e.g., ocean temperature modeling, atmospheric chemistry, etc.). The team has faced issues with code integration, where new contributions occasionally break existing functionalities or cause unexpected results, leading to delays in their research. You are considering the adoption of **Continuous Integration**.

## Question

Which of the following best describes Continuous Integration and its benefits for this project?

a) Continuous Integration is a practice where team members work in isolation to ensure their code is perfect before integrating it once at the end of the project, helping to avoid conflicts and errors.

b) Continuous Integration involves the use of specialized software to automatically translate code into multiple programming languages, making it more versatile and reducing workload.

c) Continuous Integration is a development practice where team members frequently integrate their work, often several times a day, to detect and fix integration issues early, thereby improving collaboration and code quality.

d) Continuous Integration is a method where team members manually review each other's code at the end of each day, ensuring that the code meets quality standards and is ready for client presentation.

e) Continuous Integration refers to the continuous updating of software to incorporate user feedback and new features, ensuring the software evolves to meet user needs.

<small> correct answer: c) </small>
Binary file added modules/testing/media/benefits_of_ci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/testing/media/cicd_scheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/testing/media/testing-motivation1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/testing/media/testing-motivation2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/testing/media/testing-motivation3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions modules/testing/presentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Presentation

## Author

### Date

---

<!-- .slide: data-state="title" -->

## Software Testing

---

<!-- .slide: data-state="standard" -->

## What is software testing?

> “Software testing is the process of evaluating and verifying that a software product or application does what it’s supposed to do. The benefits of good testing include preventing bugs and improving performance.”
<small>[From IBM Featured Topics](https://www.ibm.com/topics/software-testing) </small>

Note:

What is software testing?

Software testing is the process of evaluating and verifying that a software and its components meet specified requirements and work as expected. Its primary purpose is to identify defects, errors, flaws, or bugs early in the development process.

Software testing can be done manually, where a human actively uses the software to observe for defects, or automatically, where test scripts or tools are used to execute tests.

Untested software can be compared to uncalibrated experimental devices.

---

<!-- .slide: data-state="standard" -->

## Consequences of not testing your (research) software

<center>
<img src="media/testing-motivation1.png" width="30%">
<img src="media/testing-motivation2.png" width="30%">
<img src="media/testing-motivation3.png" width="30%">
</center>


<small> Find the complete articles [here](https://www.science.org/doi/full/10.1126/science.314.5807.1856), [here](https://arstechnica.com/information-technology/2019/10/chemists-discover-cross-platform-python-scripts-not-so-cross-platform/), and [here](https://www.wired.com/2010/11/1110mars-climate-observer-report/) </small>

Note:

There are several examples in which the lack of proper software testings resulted in serious consequences.

The first article from 2006 reports about a software flaw (a plus sign in place of a minus sign) that lead to a retraction of 5 scientific articles.

In the second from 2019, researchers found that a programming error in a set of Python scripts commonly used for computational analysis of chemistry data returned varying results based on which operating system they were run on—throwing doubt on the results of more than 150 published chemistry studies.

The loss of the Mars Climate Orbiter in 1999 is another prominent example of a catastrophe caused by a software error, specifically a unit conversion mistake.

There is also the case of the Ariane flight V88, an European Space Agency rocket which was destroyed just 40 seconds after its launch due to a software bug; see https://en.wikipedia.org/wiki/Ariane_flight_V88.

---

<!-- .slide: data-state="standard" -->

## Why testing your software ?

- Ensure software reliability, validity, and reproducibility.
- Confirm correct installation and demonstrate use.
- Boost developer confidence for contributions and modifications.
- Maintain expected software functionality.
- Simplify and manage code complexity.

Note:

Why testing your software is so crucial?

Specifically for research software, tests are vital for ensuring the reliability, validity, and reproducibility of your scientific results.

They help users by enabling them confirm that the software is installed correctly, providing usage examples.

Tests also help other developers modify and contribute to your software. A good test suite gives collaborators confidence to make modifications without breaking existing functionalities.
They preserve the expected functionality of the software.

Manage complexity: Code that is easy to test is often easier to understand and maintain.

---

<!-- .slide: data-state="standard" -->

## Types of testing

- **Unit tests**: Assess individual components for correctness.
- **Integration tests**: Verify interactions between different parts of the software.
- **System tests**: Evaluate the complete and integrated software system.
- **Regression tests**: Ensure new changes don’t disrupt existing functionality.

Note:

There are several types of software testing, each of which with its own purpose.

In unit tests each individual unit of a software is tested separately. The purpose is to ensure that each component of the software works as expected.

Integration tests are a level of software testing where individual units are combined and tested as a group. The purpose of this level of testing is to expose faults in the interaction between integrated units.

The complete, integrated system is checked via the so-called system tests. The purpose here is to evaluate whether the software as a whole gives the correct outputs for given inputs.

Finally, regression tests check for unexpected side-effects in existing features after changes.
---

<!-- .slide: data-state="standard" -->

## Continuous Integration and Continuous Deployment (CI/CD)

<center>
<img src="media/cicd_scheme.png" width="80%">
</center>

Note:

Continuous Integration (CI) is a practice in software development where team members regularly integrate their individual code changes, often several times a day, into a shared remote repository. After every integration, a working version of the project is build and the software's test suite is run automatically, making it possible to identify defects, errors, flaws, or bugs introduced by changes early in the development process. This helps keep the code up-to-date and reduces the chances of major issues when combining everyone's work.

Continuous deployment (CD) is the next step after CI in the CI/CD pipeline shown in the figure. CD is the practice of automatically deploying every working version of the project that passes the automated testing phase to its end-users.

---

<!-- .slide: data-state="standard" -->

## Benefits of continuous integration

<center>
<img src="media/benefits_of_ci.png" width="80%">
</center>

---

<!-- .slide: data-state="standard" -->

## Take home messages

- Software testing is key for quality, reliability, and reproducibility
- Unit tests verify individual components, integration tests check component interactions
- CI/CD streamline development and enhance deployment efficiency.

---

<!-- .slide: data-state="keepintouch" -->


www.esciencecenter.nl

[email protected]
28 changes: 28 additions & 0 deletions modules/testing/reading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Reading material

## Testing
Follow the links below to read more about software testing.

### The Turing Way
Read in the Turing Way about [Code Testing](https://the-turing-way.netlify.app/reproducible-research/testing).

### Code Refinery
Read in CodeRefinery about [Automated testing](https://coderefinery.github.io/testing/motivation/)

### IBM
Link to an [IBM article](https://www.ibm.com/topics/software-testing).

### arXiv
Read this interesting article about [Testing Research Software](https://arxiv.org/abs/2205.15982)

## CI/CD
Follow the links below to read more about CI/CD.

### The Turing Way
Read in the Turing Way about [Continuous Integration](https://the-turing-way.netlify.app/reproducible-research/ci).

### Code Refinery
Read in CodeRefinery about [Continuous integration](https://coderefinery.github.io/testing/continuous-integration/)

### ByteByteGo Newsletter
Read in ByteByteGo newsletter about [A Crash Course in CI/CD](https://blog.bytebytego.com/p/a-crash-course-in-cicd)

0 comments on commit 86e6dcb

Please sign in to comment.