Title: Consistent syntax for suite/test/context annotations · Issue #1016 · utPLSQL/utPLSQL · GitHub
Open Graph Title: Consistent syntax for suite/test/context annotations · Issue #1016 · utPLSQL/utPLSQL
X Title: Consistent syntax for suite/test/context annotations · Issue #1016 · utPLSQL/utPLSQL
Description: Current state Currently --%suite and --%test annotations take description as argument. The --%context annotation doesn't allow that and expects name to be given instead. This is inconsistent and leads to confusion when using the framewor...
Open Graph Description: Current state Currently --%suite and --%test annotations take description as argument. The --%context annotation doesn't allow that and expects name to be given instead. This is inconsistent and le...
X Description: Current state Currently --%suite and --%test annotations take description as argument. The --%context annotation doesn't allow that and expects name to be given instead. This is inconsistent an...
Opengraph URL: https://github.com/utPLSQL/utPLSQL/issues/1016
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consistent syntax for suite/test/context annotations","articleBody":"**Current state**\r\n\r\nCurrently `--%suite` and `--%test` annotations take `description` as argument.\r\nThe `--%context` annotation doesn't allow that and expects `name` to be given instead.\r\n\r\nThis is inconsistent and leads to confusion when using the framework.\r\n\r\nEngineers expect simplicity and ease of use from the framework which isn't the case with `--%context` annotation.\r\n\r\nConsider the below example:\r\n```sql\r\ncreate or replace package queue_spec as\r\n --%suite(Queue specification)\r\n\r\n --%context(A new queue)\r\n\r\n --%test(Cannot be created with non positive bounding capacity)\r\n procedure non_positive_bounding_cap;\r\n\r\n --%endcontext\r\nend;\r\n```\r\n\r\nWith this package, current implementation of utPLSQL gives the following:\r\n\r\n| suitepath | description | name |\r\n|-----------|------------|------|\r\n| queue_spec | Queue specification | queue_spec |\r\n| queue_spec.A new queue | A new queue | A new queue |\r\n| queue_spec.A new queue.non_positive_bounding_cap | Cannot be created with non positive bounding capacity | non_positive_bounding_cap |\r\n\r\n- The name of suite comes from package name and description from annotation\r\n- The name of test comes from procedure name and description from annotation \r\n- The name of context is take from annotation and description is copied from name\r\n\r\nThe above package spec is not really valid, as context name should not contain any whitespace or full stop characters. Context name rules should conform to naming rules for Oracle objects.\r\n\r\nutPLSQL does not give any warning on invalid context names too.\r\n\r\nThe proper implementation of the above package following current framework behavior should be more like below.\r\n```sql\r\ncreate or replace package queue_spec as\r\n --%suite(Queue specification)\r\n\r\n --%context(a_new_queue)\r\n --%displayname(A new queue)\r\n\r\n --%test(Cannot be created with non positive bounding capacity)\r\n procedure non_positive_bounding_cap;\r\n\r\n --%endcontext\r\nend;\r\n```\r\n\r\nThe above is confusing, hard to remember and easy to confuse engineers.\r\n\r\n| suitepath | description | name |\r\n|-----------|------------|------|\r\n| queue_spec | Queue specification | queue_spec |\r\n| queue_spec.a_new_queue | A new queue | a_new_queue |\r\n| queue_spec.a_new_queue.non_positive_bounding_cap | Cannot be created with non positive bounding capacity | non_positive_bounding_cap |\r\n\r\n\r\n**Describe the solution you'd like**\r\n\r\nI suggest to change the current behavior so that the `--%context` annotation accepts description as argument and is aligned with `--%test` and `--suite` annotations.\r\n\r\nFramework would need to provide a way for giving an explicit name to a context as well as allow for implicit naming, if users don't care about context names. \r\n\r\nRules:\r\n- if no `name` is specified for a context, the context name is defaulted to `nested_context_#N` where `N` is the consecutive number of the context inside it's parent.\r\n- if a `name` is specified for the context, the name is used instead\r\n- if provided `name` is not valid, a warning is given and the name is defaulted to `nested_context_#N` \r\n\r\n\r\nGiven the original example.\r\n```sql\r\ncreate or replace package queue_spec as\r\n --%suite(Queue specification)\r\n\r\n --%context(A new queue)\r\n\r\n --%test(Cannot be created with non positive bounding capacity)\r\n procedure non_positive_bounding_cap;\r\n\r\n --%endcontext\r\nend;\r\n```\r\n\r\nThe new implementation would give the following results:\r\n\r\n| suitepath | description | name |\r\n|-----------|------------|------|\r\n| queue_spec | Queue specification | queue_spec |\r\n| queue_spec.nested_context_#1 | A new queue | nested_context_#1 |\r\n| queue_spec.nested_context_#1.non_positive_bounding_cap | Cannot be created with non positive bounding capacity | non_positive_bounding_cap |\r\n\r\nTo give an explicit name to the context, users would use syntax:\r\n```sql\r\ncreate or replace package queue_spec as\r\n --%suite(Queue specification)\r\n\r\n --%context(A new queue)\r\n --%name(a_new_queue)\r\n\r\n --%test(Cannot be created with non positive bounding capacity)\r\n procedure non_positive_bounding_cap;\r\n\r\n --%endcontext\r\nend;\r\n```\r\n\r\n\r\n**Describe alternatives you've considered**\r\n\r\nAn alternative would be to convert the description into context name by:\r\n- making it lower-case\r\n- trimming leading and trailing whitespace and full stop characters\r\n- replacing all the whitespaces, full stops and special characters with underscores\r\n\r\nThis could work pretty well for some many use-cases.\r\n\r\n```sql\r\ncreate or replace package queue_spec as\r\n --%suite(Queue specification)\r\n\r\n --%context(A new queue)\r\n\r\n --%test(Cannot be created with non positive bounding capacity)\r\n procedure non_positive_bounding_cap;\r\n\r\n --%endcontext\r\nend;\r\n```\r\n\r\nThe alternative implementation would give the following results:\r\n\r\n| suitepath | description | name |\r\n|-----------|------------|------|\r\n| queue_spec | Queue specification | queue_spec |\r\n| queue_spec.a_new_queue | A new queue | a_new_queue |\r\n| queue_spec.a_new_queue.non_positive_bounding_cap | Cannot be created with non positive bounding capacity | non_positive_bounding_cap |\r\n\r\n\r\nWe would still need to use default context names if no description is provided.\r\n","author":{"url":"https://github.com/jgebal","@type":"Person","name":"jgebal"},"datePublished":"2019-10-28T12:08:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1016/utPLSQL/issues/1016"}
| 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:a8b74585-de37-416f-d5a6-03c83d1f77d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE32:FE622:BB58B3:1011401:6A62F4E3 |
| html-safe-nonce | 126c706ec5c4e05146ea3b9735feb852fe58a2331e3c3a5a570920d633f76d80 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTMyOkZFNjIyOkJCNThCMzoxMDExNDAxOjZBNjJGNEUzIiwidmlzaXRvcl9pZCI6Ijc4NzI3MzA4NjQxNTc5MTQzMzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fafdd5e217aeec15dcc00262820ff8e2b5215924a53957d1ebe497d14d10593a |
| hovercard-subject-tag | issue:513264973 |
| 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/utPLSQL/utPLSQL/1016/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c529bcf953fce0e386291d27dced4c4e1791949c71f3985e5a2bf1aef049dff4/utPLSQL/utPLSQL/issues/1016 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c529bcf953fce0e386291d27dced4c4e1791949c71f3985e5a2bf1aef049dff4/utPLSQL/utPLSQL/issues/1016 |
| og:image:alt | Current state Currently --%suite and --%test annotations take description as argument. The --%context annotation doesn't allow that and expects name to be given instead. This is inconsistent and le... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jgebal |
| hostname | github.com |
| expected-hostname | github.com |
| None | b415018e190e73858133ddcaa36acce7b3f3572fe54dda84bd3b21a6ec714c30 |
| turbo-cache-control | no-preview |
| go-import | github.com/utPLSQL/utPLSQL git https://github.com/utPLSQL/utPLSQL.git |
| octolytics-dimension-user_id | 15661281 |
| octolytics-dimension-user_login | utPLSQL |
| octolytics-dimension-repository_id | 50728220 |
| octolytics-dimension-repository_nwo | utPLSQL/utPLSQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 50728220 |
| octolytics-dimension-repository_network_root_nwo | utPLSQL/utPLSQL |
| 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 | 22f98521e99f504294ab0812b66104d50eb75a70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width