{"action":"created","comment":{"url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/comments/229684388","pull_request_review_id":170233425,"id":229684388,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTY4NDM4OA==","diff_hunk":"@@ -0,0 +1,211 @@\n+# Unit test guidelines\n+\n+Wring unit tests can be done in a great many ways, but all of them have some default rules to adhere to. Further more we recommend using Quick & Nimble for unit tests in Swift, with writing mocks as described below.\n+\n+## General guidelines\n+\n+- Never use a shared instance of a class in any part of a unit test, i.e.\n+```swift\n+UserDefaults.sharedInstance\n+UIApplication.sharedApplication\n+```\n+- Never use any form of (async) waiting directly in the tests\n+```swift\n+sleep()\n+NSRunLoop.current\n+while (value != expected) { }\n+```\n+\n+To wait for (async) code to finish use `XCTestExpectation` when writing a `XCTest` or `expectEventually` when writing a spec using `Quick & Nimble`\n+\n+## Quick & Nimble guidelines\n+\n+Quick & Nimble provide 5 important DSL keywords, below follow which should be used in different scenarios.\n+\n+See [PriceFormatterSpec.swift](https://jmb.gitlab.schubergphilis.com/JumboApp/jumbo-ios/blob/a5d61a077169ea88f4439bae5e06becb82601975/Jumbo/Tests/JumboTests/Products/Resources/PriceFormatterSpec.swift) for a example following these guidelines.\n+\n+### Describe\n+\n+Use describe when `starting a spec function`. This is also the place where the `sut` is defined:\n+```swift\n+class BoolSpec: QuickSpec {\n+    override func spec() {\n+        describe(\"Bool\") {\n+            var sut: Bool!\n+\n+            ...\n+        }\n+    }\n+}\n+\n+```\n+\n+The other use of describe is to describe `a piece functionality within the class` under test. \n+\n+**Rule of thumb**: When adding a `beforeEach` statement in a `describe` it should only prepare for `context` calls to follow. Don't execute any code on the class under test. \n+\n+For example a `negate()` function within a `Bool` class;\n+\n+```swift\n+class BoolSpec: QuickSpec {\n+    override func spec() {\n+        describe(\"Bool\") {\n+            var sut: Bool!\n+\n+            describe(\"negating the value\") {\n+                ...\n+            }\n+        }\n+    }\n+}\n+\n+```\n+\n+\n+- Context\n+\n+Use context to define the different flows of the a certain functionality within the `describe` closure, for example;\n+\n+```swift\n+class BoolSpec: QuickSpec {\n+    override func spec() {\n+        describe(\"Bool\") {\n+            var sut: Bool!\n+\n+            describe(\"negating the value\") {\n+                context(\"negating a true value\") {\n+                    ...\n+                }\n+\n+                context(\"negating a false value\") {\n+                    ...\n+                }\n+            }\n+        }\n+    }\n+}\n+\n+```\n+\n+- BeforeEach","path":"swift/unit_tests.md","position":90,"original_position":90,"commit_id":"4cecee5e336a0c7cb339ef9d5b81a5bafe800887","original_commit_id":"4cecee5e336a0c7cb339ef9d5b81a5bafe800887","user":{"login":"RuudPuts","id":1516529,"node_id":"MDQ6VXNlcjE1MTY1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1516529?v=4","gravatar_id":"","url":"https://api.github.com/users/RuudPuts","html_url":"https://github.com/RuudPuts","followers_url":"https://api.github.com/users/RuudPuts/followers","following_url":"https://api.github.com/users/RuudPuts/following{/other_user}","gists_url":"https://api.github.com/users/RuudPuts/gists{/gist_id}","starred_url":"https://api.github.com/users/RuudPuts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuudPuts/subscriptions","organizations_url":"https://api.github.com/users/RuudPuts/orgs","repos_url":"https://api.github.com/users/RuudPuts/repos","events_url":"https://api.github.com/users/RuudPuts/events{/privacy}","received_events_url":"https://api.github.com/users/RuudPuts/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2018-10-31T13:07:32Z","updated_at":"2018-10-31T13:12:59Z","html_url":"https://github.com/jumbo-tech-campus/Styleguide/pull/4#discussion_r229684388","pull_request_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/comments/229684388"},"html":{"href":"https://github.com/jumbo-tech-campus/Styleguide/pull/4#discussion_r229684388"},"pull_request":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4"}},"in_reply_to_id":229596010},"pull_request":{"url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4","id":226930858,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2OTMwODU4","html_url":"https://github.com/jumbo-tech-campus/Styleguide/pull/4","diff_url":"https://github.com/jumbo-tech-campus/Styleguide/pull/4.diff","patch_url":"https://github.com/jumbo-tech-campus/Styleguide/pull/4.patch","issue_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/4","number":4,"state":"open","locked":false,"title":"Moved Swift unit test guidelines to this repo","user":{"login":"RuudPuts","id":1516529,"node_id":"MDQ6VXNlcjE1MTY1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1516529?v=4","gravatar_id":"","url":"https://api.github.com/users/RuudPuts","html_url":"https://github.com/RuudPuts","followers_url":"https://api.github.com/users/RuudPuts/followers","following_url":"https://api.github.com/users/RuudPuts/following{/other_user}","gists_url":"https://api.github.com/users/RuudPuts/gists{/gist_id}","starred_url":"https://api.github.com/users/RuudPuts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuudPuts/subscriptions","organizations_url":"https://api.github.com/users/RuudPuts/orgs","repos_url":"https://api.github.com/users/RuudPuts/repos","events_url":"https://api.github.com/users/RuudPuts/events{/privacy}","received_events_url":"https://api.github.com/users/RuudPuts/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-30T13:54:05Z","updated_at":"2018-10-31T13:12:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49e305424fc837866b6c0e3a30aa07a5330df345","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4/commits","review_comments_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4/comments","review_comment_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/4/comments","statuses_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/statuses/4cecee5e336a0c7cb339ef9d5b81a5bafe800887","head":{"label":"RuudPuts:swift_unit-test-guidelines","ref":"swift_unit-test-guidelines","sha":"4cecee5e336a0c7cb339ef9d5b81a5bafe800887","user":{"login":"RuudPuts","id":1516529,"node_id":"MDQ6VXNlcjE1MTY1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1516529?v=4","gravatar_id":"","url":"https://api.github.com/users/RuudPuts","html_url":"https://github.com/RuudPuts","followers_url":"https://api.github.com/users/RuudPuts/followers","following_url":"https://api.github.com/users/RuudPuts/following{/other_user}","gists_url":"https://api.github.com/users/RuudPuts/gists{/gist_id}","starred_url":"https://api.github.com/users/RuudPuts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuudPuts/subscriptions","organizations_url":"https://api.github.com/users/RuudPuts/orgs","repos_url":"https://api.github.com/users/RuudPuts/repos","events_url":"https://api.github.com/users/RuudPuts/events{/privacy}","received_events_url":"https://api.github.com/users/RuudPuts/received_events","type":"User","site_admin":false},"repo":{"id":155393703,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUzOTM3MDM=","name":"Styleguide","full_name":"RuudPuts/Styleguide","private":false,"owner":{"login":"RuudPuts","id":1516529,"node_id":"MDQ6VXNlcjE1MTY1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1516529?v=4","gravatar_id":"","url":"https://api.github.com/users/RuudPuts","html_url":"https://github.com/RuudPuts","followers_url":"https://api.github.com/users/RuudPuts/followers","following_url":"https://api.github.com/users/RuudPuts/following{/other_user}","gists_url":"https://api.github.com/users/RuudPuts/gists{/gist_id}","starred_url":"https://api.github.com/users/RuudPuts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuudPuts/subscriptions","organizations_url":"https://api.github.com/users/RuudPuts/orgs","repos_url":"https://api.github.com/users/RuudPuts/repos","events_url":"https://api.github.com/users/RuudPuts/events{/privacy}","received_events_url":"https://api.github.com/users/RuudPuts/received_events","type":"User","site_admin":false},"html_url":"https://github.com/RuudPuts/Styleguide","description":"Style guides for Jumbo projects ","fork":true,"url":"https://api.github.com/repos/RuudPuts/Styleguide","forks_url":"https://api.github.com/repos/RuudPuts/Styleguide/forks","keys_url":"https://api.github.com/repos/RuudPuts/Styleguide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RuudPuts/Styleguide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RuudPuts/Styleguide/teams","hooks_url":"https://api.github.com/repos/RuudPuts/Styleguide/hooks","issue_events_url":"https://api.github.com/repos/RuudPuts/Styleguide/issues/events{/number}","events_url":"https://api.github.com/repos/RuudPuts/Styleguide/events","assignees_url":"https://api.github.com/repos/RuudPuts/Styleguide/assignees{/user}","branches_url":"https://api.github.com/repos/RuudPuts/Styleguide/branches{/branch}","tags_url":"https://api.github.com/repos/RuudPuts/Styleguide/tags","blobs_url":"https://api.github.com/repos/RuudPuts/Styleguide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RuudPuts/Styleguide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RuudPuts/Styleguide/git/refs{/sha}","trees_url":"https://api.github.com/repos/RuudPuts/Styleguide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RuudPuts/Styleguide/statuses/{sha}","languages_url":"https://api.github.com/repos/RuudPuts/Styleguide/languages","stargazers_url":"https://api.github.com/repos/RuudPuts/Styleguide/stargazers","contributors_url":"https://api.github.com/repos/RuudPuts/Styleguide/contributors","subscribers_url":"https://api.github.com/repos/RuudPuts/Styleguide/subscribers","subscription_url":"https://api.github.com/repos/RuudPuts/Styleguide/subscription","commits_url":"https://api.github.com/repos/RuudPuts/Styleguide/commits{/sha}","git_commits_url":"https://api.github.com/repos/RuudPuts/Styleguide/git/commits{/sha}","comments_url":"https://api.github.com/repos/RuudPuts/Styleguide/comments{/number}","issue_comment_url":"https://api.github.com/repos/RuudPuts/Styleguide/issues/comments{/number}","contents_url":"https://api.github.com/repos/RuudPuts/Styleguide/contents/{+path}","compare_url":"https://api.github.com/repos/RuudPuts/Styleguide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RuudPuts/Styleguide/merges","archive_url":"https://api.github.com/repos/RuudPuts/Styleguide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RuudPuts/Styleguide/downloads","issues_url":"https://api.github.com/repos/RuudPuts/Styleguide/issues{/number}","pulls_url":"https://api.github.com/repos/RuudPuts/Styleguide/pulls{/number}","milestones_url":"https://api.github.com/repos/RuudPuts/Styleguide/milestones{/number}","notifications_url":"https://api.github.com/repos/RuudPuts/Styleguide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RuudPuts/Styleguide/labels{/name}","releases_url":"https://api.github.com/repos/RuudPuts/Styleguide/releases{/id}","deployments_url":"https://api.github.com/repos/RuudPuts/Styleguide/deployments","created_at":"2018-10-30T13:53:33Z","updated_at":"2018-10-30T13:53:36Z","pushed_at":"2018-10-30T13:53:47Z","git_url":"git://github.com/RuudPuts/Styleguide.git","ssh_url":"git@github.com:RuudPuts/Styleguide.git","clone_url":"https://github.com/RuudPuts/Styleguide.git","svn_url":"https://github.com/RuudPuts/Styleguide","homepage":null,"size":63,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jumbo-tech-campus:master","ref":"master","sha":"266c58726982dcd0970b46ecc7ee74b43e8b7f38","user":{"login":"jumbo-tech-campus","id":38133463,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MTMzNDYz","avatar_url":"https://avatars3.githubusercontent.com/u/38133463?v=4","gravatar_id":"","url":"https://api.github.com/users/jumbo-tech-campus","html_url":"https://github.com/jumbo-tech-campus","followers_url":"https://api.github.com/users/jumbo-tech-campus/followers","following_url":"https://api.github.com/users/jumbo-tech-campus/following{/other_user}","gists_url":"https://api.github.com/users/jumbo-tech-campus/gists{/gist_id}","starred_url":"https://api.github.com/users/jumbo-tech-campus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jumbo-tech-campus/subscriptions","organizations_url":"https://api.github.com/users/jumbo-tech-campus/orgs","repos_url":"https://api.github.com/users/jumbo-tech-campus/repos","events_url":"https://api.github.com/users/jumbo-tech-campus/events{/privacy}","received_events_url":"https://api.github.com/users/jumbo-tech-campus/received_events","type":"Organization","site_admin":false},"repo":{"id":152563740,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI1NjM3NDA=","name":"Styleguide","full_name":"jumbo-tech-campus/Styleguide","private":false,"owner":{"login":"jumbo-tech-campus","id":38133463,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MTMzNDYz","avatar_url":"https://avatars3.githubusercontent.com/u/38133463?v=4","gravatar_id":"","url":"https://api.github.com/users/jumbo-tech-campus","html_url":"https://github.com/jumbo-tech-campus","followers_url":"https://api.github.com/users/jumbo-tech-campus/followers","following_url":"https://api.github.com/users/jumbo-tech-campus/following{/other_user}","gists_url":"https://api.github.com/users/jumbo-tech-campus/gists{/gist_id}","starred_url":"https://api.github.com/users/jumbo-tech-campus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jumbo-tech-campus/subscriptions","organizations_url":"https://api.github.com/users/jumbo-tech-campus/orgs","repos_url":"https://api.github.com/users/jumbo-tech-campus/repos","events_url":"https://api.github.com/users/jumbo-tech-campus/events{/privacy}","received_events_url":"https://api.github.com/users/jumbo-tech-campus/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/jumbo-tech-campus/Styleguide","description":"Style guides for Jumbo projects ","fork":false,"url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide","forks_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/forks","keys_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/teams","hooks_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/hooks","issue_events_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/events{/number}","events_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/events","assignees_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/assignees{/user}","branches_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/branches{/branch}","tags_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/tags","blobs_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/git/refs{/sha}","trees_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/statuses/{sha}","languages_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/languages","stargazers_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/stargazers","contributors_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/contributors","subscribers_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/subscribers","subscription_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/subscription","commits_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/commits{/sha}","git_commits_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/git/commits{/sha}","comments_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/comments{/number}","issue_comment_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/comments{/number}","contents_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/contents/{+path}","compare_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/merges","archive_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/downloads","issues_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues{/number}","pulls_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls{/number}","milestones_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/milestones{/number}","notifications_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/labels{/name}","releases_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/releases{/id}","deployments_url":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/deployments","created_at":"2018-10-11T09:13:07Z","updated_at":"2018-10-31T08:16:00Z","pushed_at":"2018-10-31T08:15:59Z","git_url":"git://github.com/jumbo-tech-campus/Styleguide.git","ssh_url":"git@github.com:jumbo-tech-campus/Styleguide.git","clone_url":"https://github.com/jumbo-tech-campus/Styleguide.git","svn_url":"https://github.com/jumbo-tech-campus/Styleguide","homepage":null,"size":60,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":3,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4"},"html":{"href":"https://github.com/jumbo-tech-campus/Styleguide/pull/4"},"issue":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/4"},"comments":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/jumbo-tech-campus/Styleguide/statuses/4cecee5e336a0c7cb339ef9d5b81a5bafe800887"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"RuudPuts"}}