Title: Refactoring for mature native authoring, TDD, and scalability of the codebase. · Issue #1711 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Refactoring for mature native authoring, TDD, and scalability of the codebase. · Issue #1711 · IfcOpenShell/IfcOpenShell
X Title: Refactoring for mature native authoring, TDD, and scalability of the codebase. · Issue #1711 · IfcOpenShell/IfcOpenShell
Description: As a self-professed TDD enthusiast who embarrassingly didn't write a single test, I've run out of excuses :) During the first year of the BlenderBIM Add-on, it was a monolithic import / export function. This was untestable and due to my ...
Open Graph Description: As a self-professed TDD enthusiast who embarrassingly didn't write a single test, I've run out of excuses :) During the first year of the BlenderBIM Add-on, it was a monolithic import / export func...
X Description: As a self-professed TDD enthusiast who embarrassingly didn't write a single test, I've run out of excuses :) During the first year of the BlenderBIM Add-on, it was a monolithic import / exp...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/1711
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refactoring for mature native authoring, TDD, and scalability of the codebase.","articleBody":"As a self-professed TDD enthusiast who embarrassingly didn't write a single test, I've run out of excuses :)\r\n\r\nDuring the first year of the BlenderBIM Add-on, it was a monolithic import / export function. This was untestable and due to my lack of IFC knowledge at the time I was not clever enough to modularise it and all the IFC entities seemed rather spaghetti-like.\r\n\r\nWith the best of intentions, at the beginning of this year the add-on was rebuilt from scratch designed to be testable. Yet, I still did not write tests. Unfortunately, the Blender UI is not fun to test, and the IfcOpenShell API is basically a database / repository layer, which requires data to test. Writing database tests are [not fun](https://stackoverflow.com/questions/145131/whats-the-best-strategy-for-unit-testing-database-driven-applications). Essentially I was lazy and now I'm paying the price. However, I think that the IfcOpenShell API has matured enough that we can now use the API itself to write tests, which'll make test writing more fun.\r\n\r\nHere's an unscientific roll through the last few bugfixes and categorising them by testable layer based on the test pyramid. Note that it's slightly less pyramid shaped because @Gorgious56 went crazy on the operator layer and focused on those problems in particular. Not all of these bugs could've been caught from tests, but they could've benefited from tests. All of these fixes have brought us closer to native authoring.\r\n\r\nBug in Blender UI:\r\nbcda3d8e (\"Minor fix\", 2021-08-29)\r\n52f4b564 (\"Minor fix. It seems as though StructRNA of type Scene may be removed during undo/redo, which results in handlers failing.\", 2021-08-22)\r\n\r\nBug in Blender operators:\r\n0ed38a41 (\"Fix #1707. Fix bug where project library browser could self reference.\", 2021-08-31)\r\ndd0a3d04 (\"Minor fix.\", 2021-08-27)\r\n3c235208 (\"Fix #1679. Again.\", 2021-08-22)\r\n8178dd33 (\"Fix #1679\", 2021-08-22)\r\n616f2841 (\"Minor fix\", 2021-08-21)\r\n6c6d4c04 (\"Fix #1672. Bug where style attributes couldn't be edited.\", 2021-08-20)\r\n11e36bf7 (\"Minor fix\", 2021-08-20)\r\n29cda050 (\"Fix error when adding opening with None object\", 2021-08-19)\r\n95f2d939 (\"Fix error when filling opening with None object\", 2021-08-19)\r\n\r\nBug in API:\r\n4accf306 (\"Add transaction support for adding elements. See #1709.\", 2021-08-31)\r\n0a2afa48 (\"Fix bug where element replacement would sometimes fail leading to various problems.\", 2021-08-30)\r\n9d4f0730 (\"Fix typo in material style assignment code\", 2021-08-30)\r\n6b33b23a (\"Fix bug when copying objects, don't copy their decomposition to prevent invalid IFCs.\", 2021-08-30)\r\n6e3484fd (\"Fix https://github.com/IfcOpenShell/IfcOpenShell/issues/1695 : (#1697)\", 2021-08-26)\r\n8fa1a998 (\"Fix bug where the pset templates with multiple applicable entities only checked the first entity\", 2021-08-25)\r\n6db1a8a8 (\"Minor fix\", 2021-08-22)\r\n6c6d4c04 (\"Fix #1672. Bug where style attributes couldn't be edited.\", 2021-08-20)\r\nb5ff3cd8 (\"Fix error due to typo\", 2021-08-19)\r\n\r\nWith this logic, I propose that a methodical, test driven approach is the way to effectively and efficiently accelerate the maturity of native authoring.\r\n\r\nI propose that all new IfcOpenShell API, Util and Core (i.e. transaction system) changes must be test-driven from now on. Similarly, all new operator level changes must also be test driven from now on. I'm happy to ignore UI testing still, as UI bugs are very rare and UI tests are expensive.\r\n\r\nI'd also like to prioritise testing on removal usecases, and a few complex ones like copy_class. We already know these are incomplete and there are TODO notes on deep purging littered here and there.\r\n\r\nI'll edit this post later with a methodical test coverage todo list so this can act as a tracker.\r\n\r\nEdit:\r\n\r\n - IfcOpenShell-python tests: **619 / 500 (100%)** as of 2023-02-01\r\n - BlenderBIM Add-on Core tests: **267 / 601 (44%)** as of 2023-02-01\r\n - BlenderBIM Add-on Tool tests: **536 / 601 (89%)** as of 2023-02-01\r\n - BlenderBIM Add-on Integration tests: **466 / 601 (78%)** as of 2023-02-01\r\n - BlenderBIM Add-on Data classes: **45 / 45 (100%)** as of 2023-02-01\r\n - Total: **1933 / 2348 (82%)** as of 2023-02-01\r\n\r\nNote: for IfcOpenShell we have two targets. One is a traditional test coverage we can measure. However it only measures what we test, so it can be artificially high. The second one is based on the number of files, with an arbitrary assumption that we need to write at least 2 tests per file (most files are a single API usecase, except for utils and core). A quick `find . -type f -iname \"*.py\" | wc -l` as a ballpark figure multiplied by 2 gives 500 tests.\r\n\r\nNote: for the BIM module `len(dir(bpy.ops.bim))` = 601, so assuming we get one test per operator (which is an obvious underestimate), we need 601 tests. However, as we cannot measure code coverage as these are tested through Blender operators, we'll use this number as I can't think of anything better. As long as the discipline of TDD is kept, this number will always go up anyway and in time traditional coverage metrics won't matter anyway.\r\n\r\nNote: for the Tool module, we assume each operation uses at least one tool. So again, we strive for the same number of tests. Again, in some ways this is an underestimate and in some ways it is an overestimate, so it is simply a number to work towards.\r\n\r\nWhen these arbitrary targets are reached, this bug will be closed. It doesn't mean the job is done, as testing is an ongoing process. However it simply means 1) the system architecture enables testing, and 2) we have proven a strong discipline for clean code. As the system matures, I expect test counts to be in the thousands.","author":{"url":"https://github.com/Moult","@type":"Person","name":"Moult"},"datePublished":"2021-08-31T02:08:29Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/1711"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e273172f-fb13-985f-5250-2e7fee6dc0d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9DE:22C2DF:452F1A:5CC338:6B04A146 |
| html-safe-nonce | 618120e3ab25b94c99544c28d01962517a68c3ab93ee4c01c9a32a0bda5bc4d8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOURFOjIyQzJERjo0NTJGMUE6NUNDMzM4OjZCMDRBMTQ2IiwidmlzaXRvcl9pZCI6IjQ1OTA5Mjk3NjE4MzYyNDUzMTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | eadf53ef2da04298121a6c6759dde570b7b1760012e56ed46a035a2009510424 |
| hovercard-subject-tag | issue:983363597 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/1711/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95ba4e865c2f299872d7529ce900a69354c8476cb90b74d52964c142f863407f/IfcOpenShell/IfcOpenShell/issues/1711 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95ba4e865c2f299872d7529ce900a69354c8476cb90b74d52964c142f863407f/IfcOpenShell/IfcOpenShell/issues/1711 |
| og:image:alt | As a self-professed TDD enthusiast who embarrassingly didn't write a single test, I've run out of excuses :) During the first year of the BlenderBIM Add-on, it was a monolithic import / export func... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Moult |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width