{"id":13432422,"url":"https://github.com/testdouble/test-smells","last_synced_at":"2025-03-16T23:31:21.122Z","repository":{"id":44306350,"uuid":"58894411","full_name":"testdouble/test-smells","owner":"testdouble","description":"A workbook repository of example test smells and what to do about them.","archived":true,"fork":false,"pushed_at":"2021-05-11T16:02:00.000Z","size":256,"stargazers_count":420,"open_issues_count":3,"forks_count":35,"subscribers_count":83,"default_branch":"main","last_synced_at":"2024-10-27T11:51:56.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testdouble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-16T01:30:39.000Z","updated_at":"2024-04-07T08:55:50.000Z","dependencies_parsed_at":"2022-08-02T14:00:31.381Z","dependency_job_id":null,"html_url":"https://github.com/testdouble/test-smells","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdouble%2Ftest-smells","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdouble%2Ftest-smells/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdouble%2Ftest-smells/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdouble%2Ftest-smells/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testdouble","download_url":"https://codeload.github.com/testdouble/test-smells/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243949906,"owners_count":20373655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T02:01:11.392Z","updated_at":"2025-03-16T23:31:20.652Z","avatar_url":"https://github.com/testdouble.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Test Smells\n\n[![Build Status](https://travis-ci.org/testdouble/test-smells.svg?branch=main)](https://travis-ci.org/testdouble/test-smells)\n[![Build status](https://ci.appveyor.com/api/projects/status/4bj4uiu7q894scg2/branch/main?svg=true)](https://ci.appveyor.com/project/searls/test-smells/branch/main)\n\nThis repository is designed to serve as a sandbox for exploring a handful of test\nsmells that are common in real-world test suites.\n\nThe examples in this repo go hand-in-hand with an interactive training workshop\nfor developers, testers, \u0026 teams who want to improve their testing game. If\nyou're interested in bringing this training to your team, please [contact us at\nTest Double](mailto:hello+testsmells@testdouble.com)!\n\n## Getting started\n\n### Node.js\n\nThis repo should work with [Node.js](http://nodejs.org) 4.x \u0026 up. We're using\nYarn to ensure everyone has a deterministic dependency tree.\n\n#### Install and run the tests with Yarn:\n\n```\n$ npm install -g yarnpkg\n$ yarn\n$ yarn test\n\n# Run a single test\n$ yarn test:one [Path to test]\n# Example:\n$ yarn test:one smells/insufficient/invisible-assertions/invisible-assertions.js\n```\n\n\n#### Install and run the tests with NPM\n\n```\n$ npm install\n$ npm test\n\n# Run a single test\n$ npm run test:one [Path to test]\n# Example:\n$ npm run test:one smells/insufficient/invisible-assertions/invisible-assertions.js\n```\n\nMost tests should pass. (If a few tests fail, that's okay. Some of the tests are\ndesigned to fail erratically.)\n\n### Ruby\n\nThis repo supports [Ruby](https://www.ruby-lang.org) 1.9 \u0026 up. Install and the\ntests with:\n\n```\n$ bundle\n$ bundle exec rake\n```\n\nMost tests should pass. (If a few tests fail, that's okay. Some of the tests are\ndesigned to fail erratically.)\n\n## How to use this Repo\n\nThis repo was created to facilitate workshops conducted by [Test\nDouble](http://testdouble.com), a software agency dedicated to improving how the\nworld makes software. It is shared here, because it may also be valuable as a\nworkbook of sorts, for you to peruse at your own direction and pace. If you're\ninterested in hearing more about what the workshop format for this project is\nlike, please [drop us a line](mailto:hello+testsmells@testdouble.com)!\n\nEach of our odorous tests are organized under the `smells/` directory and broken\ndown into these categories:\n\n* **Insufficient** - tests that fail to fully specify the behavior of their\nsubject under test\n* **Unclear** - tests whose organization and design can mislead future\nmaintainers, incidentally increasing their carrying cost\n* **Unnecessary** - tests that do more than they need to or are otherwise\ninessential\n* **Unrealistic** - tests that undermine their intended value by inappropriately\nreplacing real things with fake things\n* **Unreliable** - tests that behave erratically based on the time, machine,\nconfiguration, or environment\n\nIn each category's directory is a listing of several examples, each codified by\na test.\n\nIf you're exploring this repository without having sniffed a specific smell,\nfeel free to explore the examples by [themes](./THEMES.md).\n\n### The tests\n\nEach smell's file listing is structured the same way, starting with:\n\n#### The description\n\nEach test resides in a directory which contains a README.md file with the\nfollowing structure:\n\n* The name of the test smell \u0026 a brief description\n* The \"odor\" emanating from the example test subject and test\n* An enumeration of the problems the smell might (or might not!) indicate; for\neach potential problem:\n  * A description of the nature of the problem\n  * General tips on how to \"deodorize\" the smell\n* Details about the example\n  * A root cause analysis of the smell\n  * A challenge to the reader to improve the design of the test and/or test\n  subject\n* Language-specific notes (common examples, likelihood of occurence, etc.)\n  * Ruby\n  * JavaScript\n* Additional resources about the smell\n\nRemember, not every smell you detect in the wild indicates an actual problem!\nSmells are simply surface indications of common problems and not necessarily\nproblematic in-and-of themselves.\n\n#### The subject under test\n\nIn each test will be one to several functions meant to be the \"production\"\nsource code. Typically these would be broken out into a separate file, but to\nkeep everything straightforward, each smell is kept to a single file listing.\n\nFor the purpose of keeping the examples easy-to-understand, the subject code is\ntypically minimal and trivial, unless greater complexity is called for by the\ntest smell itself.\n\n#### Test Frameworks\n\n* Ruby tests are written in [Minitest](https://github.com/seattlerb/minitest)\n* JavaScript tests are written in our own [teenytest](https://github.com/testdouble/teenytest)\n\n### Working with the tests\n\n#### Identify the smell\n\nOnce you've read the description of the test smell, try to sniff it out among the\nfile listing's tests. Usually, only one will exhibit the smell, but use your own\njudgment to determine which tests should be reworked.\n\n#### Improve the test\n\nOnce you've detected a smell, attempt to identify which root cause provided in\nthe description is causing the smell and attempt to implement its prescription\nfor reworking the test. (In a few cases, a test's improvements will depend on\nrefactoring the subject code, as well.)\n\nRemember, the tests themselves are untested, so be sure that your\nnew-and-improved test still works! Consider forcing the test to break, verifying\nthat a message indicates the test is still doing its job before you commit your\nchanges. As we like to say, \"never trust a test you haven't seen fail.\"\n\n### Help improve this project\n\nThere are several ways you can help us make this repo more useful to other\ndevelopers trying to improve their tests. Here are some ideas of pull requests\nwe'd really appreciate for this repo:\n\n1. Additional test smells. I'm sure we didn't catch them all!\n2. URLs pointing to examples of smells. The examples in this repo are necessarily\nminimal, and as a result there is a risk that they won't sufficiently remind\npeople of their real-world tests. Additional examples can help people recognize\nthe smells in their own code\n3. Feedback about your experience. If you attended a workshop that used this repo\nor if you just took a stab at working through it yourself, please [open an\nissue](https://github.com/testdouble/test-smells/issues/new) to tell us about\nanything else you felt could be improved\n\nIf this repo helped you out and you just want to give us a high-five, please say\nhi on [twitter](https://twitter.com/testdouble) or by\n[e-mail](mailto:hello@testdouble.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestdouble%2Ftest-smells","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestdouble%2Ftest-smells","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestdouble%2Ftest-smells/lists"}