From f56bed2aa482989257842a410bdc5b18a212eb5a Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 16:20:47 -0400 Subject: [PATCH 1/8] docs: in-progress --- docs/latest/contributing/testing.md | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 docs/latest/contributing/testing.md diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md new file mode 100644 index 00000000000..94fe401e259 --- /dev/null +++ b/docs/latest/contributing/testing.md @@ -0,0 +1,69 @@ +# Contributing: Tests + +> Testing is an opinionated topic. Here is a rough overview of our testing +> philosiphy. See something you want to discuss or think should be changed? Open +> a PR and let's discuss. + +Why do we write tests? + +- Increase confidance + +You're testing implementation details if: + +- Your test does something that the consumer of your code would never do. + - IE. Using a private function +- A refactor can break your tests + +## Kinds of Tests + +| Test Type | Speed | Cost | +| --------- | -------------------- | ------------------------------------ | +| Static | :rocket: Instant | :money_with_wings: | +| Unit | :airplane: Very Fast | :money_with_wings::money_with_wings: | + +### Static Code Analysis + +Modern tooling gives us this "for free". It can catch invalid regular +expressions, unused variables, and guarantee we're calling methods/functions +with the expected paramater types. + +Example Tooling: + +- [ESLint][eslint-rules] +- [TypeScript][typescript-docs] or Flow + +Static code analysis can't test business logic. + +### Unit Tests + +... + +### Integration Tests + +... + +### End-to-End Tests + +... + +## Further Reading + +- [Assert(js) Conf 2018 Talks][assert-js-talks] + - [Write tests. Not too many. Mostly integration.](https://www.youtube.com/watch?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf) - + Kent C. Dodds + - + + + + +[eslint-rules]: https://eslint.org/docs/rules/ +[typescript-docs]: https://www.typescriptlang.org/docs/home.html +[assert-js-talks]: https://www.youtube.com/playlist?list=PLZ66c9_z3umNSrKSb5cmpxdXZcIPNvKGw +[testing-trophy]: https://twitter.com/kentcdodds/status/960723172591992832?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E960723172591992832&ref_url=https%3A%2F%2Fkentcdodds.com%2Fblog%2Fwrite-tests +[aaron-square]: https://twitter.com/Carofine247/status/966727489274961920 +[gleb-pyramid]: https://twitter.com/Carofine247/status/966764532046684160/photo/3 +[testing-pyramid]: https://dojo.ministryoftesting.com/dojo/lessons/the-mobile-test-pyramid +[testing-dorito]: https://twitter.com/denvercoder/status/960752578198843392 + From 4d219bdaca1d1cba2baf682160ea8def0d214ebf Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 17:42:33 -0400 Subject: [PATCH 2/8] Small updates --- docs/latest/contributing/testing.md | 41 ++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index 94fe401e259..4abc420c55d 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -8,18 +8,17 @@ Why do we write tests? - Increase confidance -You're testing implementation details if: - -- Your test does something that the consumer of your code would never do. - - IE. Using a private function -- A refactor can break your tests - ## Kinds of Tests -| Test Type | Speed | Cost | -| --------- | -------------------- | ------------------------------------ | -| Static | :rocket: Instant | :money_with_wings: | -| Unit | :airplane: Very Fast | :money_with_wings::money_with_wings: | +Test's buy us confidence, but not all tests are created equal. Each kind of test +has a different cost to write and maintain. More costly tests + +| Test Type | Example | Speed | Cost | +| ----------- | -------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------ | +| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | +| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | +| Integration | | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | +| End-to-end | When I click "Sign In", the page navigates to the dashboard. | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | ### Static Code Analysis @@ -38,6 +37,19 @@ Static code analysis can't test business logic. ... +#### What should be unit tested? + +Follow the top level exports. Anything that is exposed as public API should have +unit tests. These are th + +#### What should NOT be unit tested? + +You're testing implementation details if: + +- Your test does something that the consumer of your code would never do. + - IE. Using a private function +- A refactor can break your tests + ### Integration Tests ... @@ -49,9 +61,8 @@ Static code analysis can't test business logic. ## Further Reading - [Assert(js) Conf 2018 Talks][assert-js-talks] - - [Write tests. Not too many. Mostly integration.](https://www.youtube.com/watch?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf) - - Kent C. Dodds - - + - [Write tests. Not too many. Mostly integration.][kent-talk] - Kent C. Dodds + - [I see your point, but…][gleb-talk] - Gleb Bahmutov [eslint-rules]: https://eslint.org/docs/rules/ [typescript-docs]: https://www.typescriptlang.org/docs/home.html + [assert-js-talks]: https://www.youtube.com/playlist?list=PLZ66c9_z3umNSrKSb5cmpxdXZcIPNvKGw +[kent-talk]: https://www.youtube.com/watch?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf +[gleb-talk]: https://www.youtube.com/watch?v=5FnalKRjpZk + [testing-trophy]: https://twitter.com/kentcdodds/status/960723172591992832?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E960723172591992832&ref_url=https%3A%2F%2Fkentcdodds.com%2Fblog%2Fwrite-tests [aaron-square]: https://twitter.com/Carofine247/status/966727489274961920 [gleb-pyramid]: https://twitter.com/Carofine247/status/966764532046684160/photo/3 From 312e5826e67cf1835a73eb5586133d978c104bda Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 20:42:41 -0400 Subject: [PATCH 3/8] e2e test guidance --- docs/latest/contributing/testing.md | 37 +++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index 4abc420c55d..dca494eb935 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -4,21 +4,19 @@ > philosiphy. See something you want to discuss or think should be changed? Open > a PR and let's discuss. -Why do we write tests? - -- Increase confidance +Why do we write tests? The biggest and most important reason is _CONFIDANCE_. ## Kinds of Tests Test's buy us confidence, but not all tests are created equal. Each kind of test has a different cost to write and maintain. More costly tests -| Test Type | Example | Speed | Cost | -| ----------- | -------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------ | -| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | -| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | -| Integration | | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | -| End-to-end | When I click "Sign In", the page navigates to the dashboard. | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | +| Test Type | Example | Speed | Cost | +| ----------- | ------------------------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------------------------ | +| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | +| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | +| Integration | When I Click "Sign In", the page navigates to the dashboard (with mocked network requests) | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | +| End-to-end | When I click "Sign In", the page navigates to the dashboard (with no mocks) | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | ### Static Code Analysis @@ -37,12 +35,12 @@ Static code analysis can't test business logic. ... -#### What should be unit tested? +#### When should we unit test? Follow the top level exports. Anything that is exposed as public API should have unit tests. These are th -#### What should NOT be unit tested? +#### When should we avoid unit tests? You're testing implementation details if: @@ -56,13 +54,27 @@ You're testing implementation details if: ### End-to-End Tests -... +These are the most expensive tests to write and maintain. Largely because, when +they fail, they have the largest number of potential points of failure. So why +do we write them? Because they also buy us the most confidance. + +We should reserve end-to-end tests for mission critical features. A good example +is testing user authentication. If a user can't sign in to your application, +it's an emergency. Having a high degree of confidance that users can always +authenticate is very valuable. + +#### When should we test? + +Mission critical features and functionality. Unsure if we should have a test for +feature `X` or scenario `Y`? Open an issue and let's discuss. ## Further Reading - [Assert(js) Conf 2018 Talks][assert-js-talks] - [Write tests. Not too many. Mostly integration.][kent-talk] - Kent C. Dodds - [I see your point, but…][gleb-talk] - Gleb Bahmutov +- [Statc vs Unit vs Integration vs E2E Testing][kent-blog] - Kent C. Dodds + (Blog) [testing-trophy]: https://twitter.com/kentcdodds/status/960723172591992832?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E960723172591992832&ref_url=https%3A%2F%2Fkentcdodds.com%2Fblog%2Fwrite-tests [aaron-square]: https://twitter.com/Carofine247/status/966727489274961920 From 4c322067a04ccd7a3b3ec229bd8152b149e72b4a Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 22:26:02 -0400 Subject: [PATCH 4/8] Kent quote --- docs/latest/contributing/testing.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index dca494eb935..12eadc6936c 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -4,7 +4,19 @@ > philosiphy. See something you want to discuss or think should be changed? Open > a PR and let's discuss. -Why do we write tests? The biggest and most important reason is _CONFIDANCE_. +You're an engineer. You know how to write code, and writing tests isn't all that +different. But do you know why we write tests? Do you know when to write one, or +what kind of test to write? How do you know if a test is a _"good"_ test? This +document's goal is to give you the tools you need to make those determiniations. + +Okay. So why do we write tests? To increase our... :drum:: + +**CONFIDENCE** + +> I want to be confident that the code I'm writing... won't break the app that I +> have running in production. So whatever I do, I want to make sure that the +> kinds of tests I write bring me the most confidence possible and I need to be +> cognizant of the trade-offs I'm making when testing. - Kent C. Dodds ## Kinds of Tests From 95cff27b95d91aa2e968e0500d642fb6b35bd23e Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 22:54:00 -0400 Subject: [PATCH 5/8] docs: expanding on testing --- docs/latest/contributing/testing.md | 50 +++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index 12eadc6936c..9d26bc82a4e 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -7,7 +7,7 @@ You're an engineer. You know how to write code, and writing tests isn't all that different. But do you know why we write tests? Do you know when to write one, or what kind of test to write? How do you know if a test is a _"good"_ test? This -document's goal is to give you the tools you need to make those determiniations. +document's goal is to give you the tools you need to make those determinations. Okay. So why do we write tests? To increase our... :drum:: @@ -21,14 +21,16 @@ Okay. So why do we write tests? To increase our... :drum:: ## Kinds of Tests Test's buy us confidence, but not all tests are created equal. Each kind of test -has a different cost to write and maintain. More costly tests +has a different cost to write and maintain. An expensive test is worth it if it +gives us confidance that a payment is processed, but it may not be the best +choice for asserting an element's border color. -| Test Type | Example | Speed | Cost | -| ----------- | ------------------------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------------------------ | -| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | -| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | -| Integration | When I Click "Sign In", the page navigates to the dashboard (with mocked network requests) | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | -| End-to-end | When I click "Sign In", the page navigates to the dashboard (with no mocks) | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | +| Test Type | Example | Speed | Cost | +| ----------- | ------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------------------------ | +| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | +| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | +| Integration | Clicking "Sign In", navigates to the dashboard (mocked network requests) | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | +| End-to-end | Clicking "Sign In", navigates to the dashboard (no mocks) | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | ### Static Code Analysis @@ -39,9 +41,9 @@ with the expected paramater types. Example Tooling: - [ESLint][eslint-rules] -- [TypeScript][typescript-docs] or Flow +- [TypeScript][typescript-docs] or [Flow][flow-org] -Static code analysis can't test business logic. +Where it falls short: Can't test business logic. ### Unit Tests @@ -60,9 +62,13 @@ You're testing implementation details if: - IE. Using a private function - A refactor can break your tests +Where it falls short: That you're calling a dependency appropriately. + ### Integration Tests -... +Integration tests take things one step further. You + +Where it falls short: That you're passing the right data to your backend. ### End-to-End Tests @@ -75,19 +81,36 @@ is testing user authentication. If a user can't sign in to your application, it's an emergency. Having a high degree of confidance that users can always authenticate is very valuable. +Where it falls short: + #### When should we test? -Mission critical features and functionality. Unsure if we should have a test for +Mission critical features and functionality, or to cover a large breadth of +functionality until unit tests catch up. Unsure if we should have a test for feature `X` or scenario `Y`? Open an issue and let's discuss. ## Further Reading +Okay, so hopefully you have more confidance in your understanding of _why_ we +test, and the trade-offs we weigh when determining what kind of test should be +written. For the _how_, check out some of the links below, or read some of the +existing tests in this repository. + +### General + - [Assert(js) Conf 2018 Talks][assert-js-talks] - [Write tests. Not too many. Mostly integration.][kent-talk] - Kent C. Dodds - [I see your point, but…][gleb-talk] - Gleb Bahmutov -- [Statc vs Unit vs Integration vs E2E Testing][kent-blog] - Kent C. Dodds +- [Static vs Unit vs Integration vs E2E Testing][kent-blog] - Kent C. Dodds (Blog) +### End-to-end Testing w/ Cypress + +- [Getting Started](https://docs.cypress.io/guides/overview/why-cypress.html) + - Be sure to check out `Getting Started` and `Core Concepts` +- [Best Practices](https://docs.cypress.io/guides/references/best-practices.html) +- [Example Recipes](https://docs.cypress.io/examples/examples/recipes.html) + @@ -95,6 +118,7 @@ feature `X` or scenario `Y`? Open an issue and let's discuss. [eslint-rules]: https://eslint.org/docs/rules/ [typescript-docs]: https://www.typescriptlang.org/docs/home.html +[flow-org]: https://flow.org/ [assert-js-talks]: https://www.youtube.com/playlist?list=PLZ66c9_z3umNSrKSb5cmpxdXZcIPNvKGw [kent-talk]: https://www.youtube.com/watch?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf From df6fbb416d70e8a4f8838e177becb0e77a5a9c43 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 23:06:30 -0400 Subject: [PATCH 6/8] docs: better pre-amble for testing doc --- docs/latest/contributing/testing.md | 35 +++++++++++++---------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index 9d26bc82a4e..7c0b5f04559 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -9,20 +9,20 @@ different. But do you know why we write tests? Do you know when to write one, or what kind of test to write? How do you know if a test is a _"good"_ test? This document's goal is to give you the tools you need to make those determinations. -Okay. So why do we write tests? To increase our... :drum:: +Okay. So why do we write tests? To increase our... **CONFIDENCE** -**CONFIDENCE** +- If I do a large refactor, does everything still work? +- If I changed some critical piece of code, is it safe to push to production? -> I want to be confident that the code I'm writing... won't break the app that I -> have running in production. So whatever I do, I want to make sure that the -> kinds of tests I write bring me the most confidence possible and I need to be -> cognizant of the trade-offs I'm making when testing. - Kent C. Dodds +Gaining the confidence we need to answer these questions after every change is +costly. Good tests allow us to answer them without manual regression testing. +What and how we choose to test to build that confidence is nuanced. ## Kinds of Tests Test's buy us confidence, but not all tests are created equal. Each kind of test has a different cost to write and maintain. An expensive test is worth it if it -gives us confidance that a payment is processed, but it may not be the best +gives us confidence that a payment is processed, but it may not be the best choice for asserting an element's border color. | Test Type | Example | Speed | Cost | @@ -32,6 +32,10 @@ choice for asserting an element's border color. | Integration | Clicking "Sign In", navigates to the dashboard (mocked network requests) | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | | End-to-end | Clicking "Sign In", navigates to the dashboard (no mocks) | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | +- :rocket: Speed: How quickly tests run +- :money_with_wings: Cost: Time to write, and to debug when broken (more points + of failure) + ### Static Code Analysis Modern tooling gives us this "for free". It can catch invalid regular @@ -66,23 +70,21 @@ Where it falls short: That you're calling a dependency appropriately. ### Integration Tests -Integration tests take things one step further. You - -Where it falls short: That you're passing the right data to your backend. +We write integration tests to gain confidence that several units work together. +Generally, we want to mock as little as possible for these tests. In practice, +this means only mocking network requests. ### End-to-End Tests These are the most expensive tests to write and maintain. Largely because, when they fail, they have the largest number of potential points of failure. So why -do we write them? Because they also buy us the most confidance. +do we write them? Because they also buy us the most confidence. We should reserve end-to-end tests for mission critical features. A good example is testing user authentication. If a user can't sign in to your application, -it's an emergency. Having a high degree of confidance that users can always +it's an emergency. Having a high degree of confidence that users can always authenticate is very valuable. -Where it falls short: - #### When should we test? Mission critical features and functionality, or to cover a large breadth of @@ -91,11 +93,6 @@ feature `X` or scenario `Y`? Open an issue and let's discuss. ## Further Reading -Okay, so hopefully you have more confidance in your understanding of _why_ we -test, and the trade-offs we weigh when determining what kind of test should be -written. For the _how_, check out some of the links below, or read some of the -existing tests in this repository. - ### General - [Assert(js) Conf 2018 Talks][assert-js-talks] From aa48749959f29a1d68589a14ea4b1fa7b0641eea Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 23:24:03 -0400 Subject: [PATCH 7/8] Testing dorito --- docs/latest/contributing/testing.md | 51 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index 7c0b5f04559..bb725c5f2ed 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -4,6 +4,8 @@ > philosiphy. See something you want to discuss or think should be changed? Open > a PR and let's discuss. +[![testing dorito][testing-dorito-img]][testing-dorito] + You're an engineer. You know how to write code, and writing tests isn't all that different. But do you know why we write tests? Do you know when to write one, or what kind of test to write? How do you know if a test is a _"good"_ test? This @@ -16,7 +18,7 @@ Okay. So why do we write tests? To increase our... **CONFIDENCE** Gaining the confidence we need to answer these questions after every change is costly. Good tests allow us to answer them without manual regression testing. -What and how we choose to test to build that confidence is nuanced. +What and how we choose to test to increase that confidence is nuanced. ## Kinds of Tests @@ -27,8 +29,8 @@ choice for asserting an element's border color. | Test Type | Example | Speed | Cost | | ----------- | ------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------------------------ | -| Static | `addNumbers(1, '2')` was called with a `string`, `int` was expected. | :rocket: Instant | :money_with_wings: | -| Unit | `addNumbers(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | +| Static | `addNums(1, '2')` called with `string`, expected `int`. | :rocket: Instant | :money_with_wings: | +| Unit | `addNums(1, 2)` returns expected result `3` | :airplane: Fast | :money_with_wings::money_with_wings: | | Integration | Clicking "Sign In", navigates to the dashboard (mocked network requests) | :running: Okay | :money_with_wings::money_with_wings::money_with_wings: | | End-to-end | Clicking "Sign In", navigates to the dashboard (no mocks) | :turtle: Slow | :money_with_wings::money_with_wings::money_with_wings::money_with_wings: | @@ -47,50 +49,60 @@ Example Tooling: - [ESLint][eslint-rules] - [TypeScript][typescript-docs] or [Flow][flow-org] -Where it falls short: Can't test business logic. - ### Unit Tests -... +The building blocks of our libraries and applications. For these, you'll often +be testing a single function or method. Conceptually, this equates to: + +_Pure Function Test:_ + +- If I call `sum(2, 2)`, I expect the output to be `4` + +_Side Effect Test:_ + +- If I call `resetViewport(viewport)`, I expect `cornerstone.reset` to be called + with `viewport` -#### When should we unit test? +#### When to use -Follow the top level exports. Anything that is exposed as public API should have -unit tests. These are th +Anything that is exposed as public API should have unit tests. -#### When should we avoid unit tests? +#### When to avoid -You're testing implementation details if: +You're actually testing implementation details. You're testing implementation +details if: - Your test does something that the consumer of your code would never do. - IE. Using a private function - A refactor can break your tests -Where it falls short: That you're calling a dependency appropriately. - ### Integration Tests We write integration tests to gain confidence that several units work together. Generally, we want to mock as little as possible for these tests. In practice, this means only mocking network requests. +#### When to use + +... + ### End-to-End Tests These are the most expensive tests to write and maintain. Largely because, when they fail, they have the largest number of potential points of failure. So why do we write them? Because they also buy us the most confidence. -We should reserve end-to-end tests for mission critical features. A good example -is testing user authentication. If a user can't sign in to your application, -it's an emergency. Having a high degree of confidence that users can always -authenticate is very valuable. - -#### When should we test? +#### When to use Mission critical features and functionality, or to cover a large breadth of functionality until unit tests catch up. Unsure if we should have a test for feature `X` or scenario `Y`? Open an issue and let's discuss. +## Summary + +- Does your test increase confidence? +- Does the test type chosen balance the cost-to-confidence ratio? + ## Further Reading ### General @@ -127,4 +139,5 @@ feature `X` or scenario `Y`? Open an issue and let's discuss. [gleb-pyramid]: https://twitter.com/Carofine247/status/966764532046684160/photo/3 [testing-pyramid]: https://dojo.ministryoftesting.com/dojo/lessons/the-mobile-test-pyramid [testing-dorito]: https://twitter.com/denvercoder/status/960752578198843392 +[testing-dorito-img]: https://pbs.twimg.com/media/DVVHXycUMAAcN-F?format=jpg&name=4096x4096 From be6e53db0d88a438ca8f51d20bf7570eaf7d8c66 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 21 Aug 2019 23:25:31 -0400 Subject: [PATCH 8/8] Shift to bottom --- docs/latest/contributing/testing.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/latest/contributing/testing.md b/docs/latest/contributing/testing.md index bb725c5f2ed..ddffd3de2fc 100644 --- a/docs/latest/contributing/testing.md +++ b/docs/latest/contributing/testing.md @@ -4,8 +4,6 @@ > philosiphy. See something you want to discuss or think should be changed? Open > a PR and let's discuss. -[![testing dorito][testing-dorito-img]][testing-dorito] - You're an engineer. You know how to write code, and writing tests isn't all that different. But do you know why we write tests? Do you know when to write one, or what kind of test to write? How do you know if a test is a _"good"_ test? This @@ -120,6 +118,10 @@ feature `X` or scenario `Y`? Open an issue and let's discuss. - [Best Practices](https://docs.cypress.io/guides/references/best-practices.html) - [Example Recipes](https://docs.cypress.io/examples/examples/recipes.html) +## Testing Dorito + +[![testing dorito][testing-dorito-img]][testing-dorito] +