{"id":15356386,"url":"https://github.com/saravanabalagi/python_tdd_ci_tutorial","last_synced_at":"2025-10-31T19:30:30.027Z","repository":{"id":84130097,"uuid":"141062365","full_name":"saravanabalagi/python_tdd_ci_tutorial","owner":"saravanabalagi","description":"A tutorial on TDD and CI for beginners. Let's check if a number is prime or not.","archived":false,"fork":false,"pushed_at":"2019-04-22T19:35:29.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-25T20:40:54.557Z","etag":null,"topics":["ci","continous-integration","prime-numbers","tdd","test-driven-development","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"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/saravanabalagi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-15T22:20:37.000Z","updated_at":"2019-04-22T19:35:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"69027b3f-8d90-4a37-9bf6-a7f3edd66b90","html_url":"https://github.com/saravanabalagi/python_tdd_ci_tutorial","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"6a318ce5f26953dd44ca49da73815de4a2634fe5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fpython_tdd_ci_tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fpython_tdd_ci_tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fpython_tdd_ci_tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fpython_tdd_ci_tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saravanabalagi","download_url":"https://codeload.github.com/saravanabalagi/python_tdd_ci_tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239225766,"owners_count":19603162,"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":["ci","continous-integration","prime-numbers","tdd","test-driven-development","tutorial"],"created_at":"2024-10-01T12:28:34.339Z","updated_at":"2025-10-31T19:30:29.978Z","avatar_url":"https://github.com/saravanabalagi.png","language":"Python","readme":"# Python TDD CI Tutorial\n\nA nano tutorial on Test Driven Development (TDD) and Continuous Integration (CI). Let's check if a number is prime or not.\n\n[![Build Status](https://travis-ci.org/saravanabalagi/python_tdd_ci_tutorial.svg?branch=master)](https://travis-ci.org/zekedran/python_tdd_ci_tutorial)\n\n## Why Test Driven Development?\n\nTDD allows us to write software based on goals or tests. Pass all the tests and the software is done. \n\nBare minimum things we need to start is \n- some hardcoded output*\n- test cases we want the software (which you will write) to handle\n\n*that looks like output. i.e., same data structure, same data-type, etc., \n\nIt is okay to begin with a hardcoded value or random variable being outputted. And now when we run the tests, some will pass and some will fail. This should give an estimate of how much we have progressed. We then write code to make every test pass. Some test cases can be added along the way as well just like we did in this repo, if you do not know all the test cases before building the software.\n\n## Am I wasting time writing the tests?\n\nMaybe. Maybe not. Depends on\n- effort you would put in to write the tests \n- time to test all those cases manually\n- development iterations\n- number of developers involved\n\nIf it's a single developer and a one iteration build (which even small projects usually won't be) that can be easily tested manually and if it would take ages to write them as code, yes you may not want to do this. You can write the software once and for all, see if it works at the end, make quick changes or add dirty hacks just to get it working, hand it over and done, right?\n\nBut unfortunately, even a very simple task like `is_prime(number)` would require multiple iterations. Every single time you make changes, you can check if the change you made has broken your app or not. \n\nIt would become so messy when more than one developer is involved. How do I know if I broke the code, or my colleague broke it? Run the tests before and after your colleague's commit, and voila! You know who the criminal is ;)  \n\nAnd remember, passing the tests do not mean your code is bug-free, it just means that it passes the test cases that we aimed for. \n\n## Why Continuous Integration?\n\nWith CI, we can be sure if this piece of software will work just the way we would expect on any machine with a given configuration in the world. In this case, we ensure this software runs on any machine that can run\n\n  - Python 2.6\n  - Python 2.7\n  - Python 3.4\n  - Python 3.5\n  - Python 3.6\n  - Python 3.7-dev\n  \nYou would want to use CI unless you are happy if it runs only on your machine (which has it's own environment variables and specific versions of dev-software installed) or have plenty of time to test your app on all different versions manually and you won't get bored at all ;)\n\nThat's an example of something as simple as `is_prime()` breaking for a few versions of python. Yes, expect for things to break when it leaves your computer. It happens so often and it's common :D\n\n![Travis](travis-screenshot.png)\n  \n## How do I start?\n\nCheck the commit history of this repo and that should help you get started.\n\n## MIT License\n\nCopyright (c) 2018 Saravanabalagi Ramachandran\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanabalagi%2Fpython_tdd_ci_tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaravanabalagi%2Fpython_tdd_ci_tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanabalagi%2Fpython_tdd_ci_tutorial/lists"}