{"id":15685264,"url":"https://github.com/tfrommen/testable-code","last_synced_at":"2025-07-08T23:34:56.162Z","repository":{"id":57067449,"uuid":"54794602","full_name":"tfrommen/testable-code","owner":"tfrommen","description":"Example code for the talk \"How (Not) to Write Testable Code\" at WordCamp Nuremberg, 2016.","archived":false,"fork":false,"pushed_at":"2017-01-22T14:02:28.000Z","size":39,"stargazers_count":9,"open_issues_count":13,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T12:12:00.200Z","etag":null,"topics":["testability","unit-testing"],"latest_commit_sha":null,"homepage":"https://slides.tfrommen.de/testable-code/","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfrommen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-26T18:59:32.000Z","updated_at":"2023-02-23T20:34:36.000Z","dependencies_parsed_at":"2022-08-24T14:54:07.053Z","dependency_job_id":null,"html_url":"https://github.com/tfrommen/testable-code","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/tfrommen%2Ftestable-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Ftestable-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Ftestable-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Ftestable-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfrommen","download_url":"https://codeload.github.com/tfrommen/testable-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252921953,"owners_count":21825632,"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":["testability","unit-testing"],"created_at":"2024-10-03T17:24:29.815Z","updated_at":"2025-05-07T16:53:54.389Z","avatar_url":"https://github.com/tfrommen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How (Not) to Write Testable Code\n\nThis repository contains example code for the according talk at WordCamp Nuremberg, 2016.\n\n## Unit Test Examples\n\nThe first part of the talk is about unit testing. After a short summary, you can see several unit test examples. This repository includes the complete and fully documented versions of the presented [PHP unit tests](php/0-unit-test-examples) as well as the respective [JavaScript unit tests](js/0-unit-test-examples).\n\n### Running the Tests\n\nYou want to run the tests yourself? Here's how:\n\n#### JavaScript\n\nIn order to run the JavaScript tests, you have to install the required [npm](https://www.npmjs.com/) packages first.\n\nUsing [Yarn](https://www.npmjs.com/package/yarn):\n\n```shell\n$ yarn \u0026\u0026 yarn run test\n```\n\nUsing [npm](https://www.npmjs.com/package/npm):\n\n```shell\n$ npm i \u0026\u0026 npm run test\n```\n\n#### PHP\n\nIn order to run the PHP tests, you have to install the required [Composer](https://getcomposer.org/) packages first.\n\n```shell\n$ composer install \u0026\u0026 vendor/bin/phpunit\n```\n\n## Bad Practices\n\nThe second and main part of the talk then is about code examples that are either hard to test, or not testable at all. As with the unit test examples, this repository also includes the bad practice [PHP code](php/1-bad-practices/src) and [JavaScript code](js/1-bad-practices/src) examples.\n\nSince only presenting _bad_ (i.e., hard-to-test) code doesn't do any good, this repository also includes improved versions of the code. For each of the code examples, you can find an according [pull request](https://github.com/tfrommen/testable-code/pulls). By means of the diff view, you can easily compare the original and the improved code.\n\nFeel free to [fork this repository](https://github.com/tfrommen/testable-code/fork), and work on possible tests, if you like.\n\n## Changelog\n\n[Changelog](CHANGELOG.md).\n\n## License\n\nCopyright (c) 2016 Thorsten Frommen\n\nThis code is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfrommen%2Ftestable-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfrommen%2Ftestable-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfrommen%2Ftestable-code/lists"}