Skip to content

Commit

Permalink
Improve learning hour description
Browse files Browse the repository at this point in the history
  • Loading branch information
emilybache committed Jan 16, 2024
1 parent 995abf2 commit 924003a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions _learning_hours/test_design/test_design_assertions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
theme: test_design
title: Tests Have Assertions
title: Unit Tests Should Find Bugs
kata: calc_stats
difficulty: 1
author: emilybache
affiliation: Bache Consulting
---

# Tests Have Assertions
# Unit Tests Should Find Bugs

This learning hour is about basic test design including assertions.

Expand All @@ -20,27 +20,31 @@ This learning hour is about basic test design including assertions.
## Session Outline

* 5 min connect: What is an automated unit test
* 10 min concept: Test Design with assertions
* 10 min concept: Unit Test Design
* 35 min concrete: Write some tests
* 5 min conclusions: When to do this


### Connect: Three facts
What is an automated unit test? Give me [three facts](/activities/connect/three_facts.html) about it.

### Concept: Test Design with assertions
### Concept: Unit Test Design
Briefly explain the most important things about test design. For example:

The first thing about a test case is it has a name that must be unique. Usually you put it in a test class with the same name as the class being tested, so class "ABC" would have a test named "ABCTest". Each test case is a test method in that class. Name the test method after the scenario you are testing. A test will usually fail if the code being tested throws an exception, but often you include an assertion to check what happened if no exception was thrown. Tests should fail if the thing you are testing has a bug in it.
A unit test should fail if the thing you are testing has a bug in it. We are trying to achieve [Self Testing Code](https://www.martinfowler.com/bliki/SelfTestingCode.html). When a test fails you want to understand as quickly as possible what is wrong. Show a failing test in a test runner. Point out how to find the test name, the failure message, and how to navigate to the line of code responsible.

Make sure they have access to the documentation for their test framework. Explain how to assert for equality and assert that an exception is thrown.

### Concrete
Write some test cases for some existing code that has well-marked bugs in. For example [CalcStats](https://github.com/emilybache/CalcStats-TestDesign-Kata). For each method to be tested:
Write some test cases for some existing code that has well-marked bugs in. For example [CalcStats](https://github.com/emilybache/CalcStats-TestDesign-Kata). Make sure to explain what the code is supposed to do as well as that it also contains bugs that are not marked.

* Write a test that passes.
* Write a test that fails because of the marked bug.
Instructions:

* Identify a bug by reading the production code
* Write a test that fails because of this bug.
* Make sure the error message is clear about what the bug is.
* Fix the bug and make sure all the tests pass.
* Find a new bug and repeat.

### Conclusions
What is important to remember when writing unit tests? [Explain the main idea]({% link _activities/conclusions/explain_main_idea.md %})

0 comments on commit 924003a

Please sign in to comment.