{"action":"created","issue":{"url":"https://api.github.com/repos/pester/Pester/issues/317","labels_url":"https://api.github.com/repos/pester/Pester/issues/317/labels{/name}","comments_url":"https://api.github.com/repos/pester/Pester/issues/317/comments","events_url":"https://api.github.com/repos/pester/Pester/issues/317/events","html_url":"https://github.com/pester/Pester/issues/317","id":69910789,"number":317,"title":"Is there a style guide for Pester tests?","user":{"login":"alx9r","id":11237922,"avatar_url":"https://avatars.githubusercontent.com/u/11237922?v=3","gravatar_id":"","url":"https://api.github.com/users/alx9r","html_url":"https://github.com/alx9r","followers_url":"https://api.github.com/users/alx9r/followers","following_url":"https://api.github.com/users/alx9r/following{/other_user}","gists_url":"https://api.github.com/users/alx9r/gists{/gist_id}","starred_url":"https://api.github.com/users/alx9r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alx9r/subscriptions","organizations_url":"https://api.github.com/users/alx9r/orgs","repos_url":"https://api.github.com/users/alx9r/repos","events_url":"https://api.github.com/users/alx9r/events{/privacy}","received_events_url":"https://api.github.com/users/alx9r/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-21T17:51:34Z","updated_at":"2015-04-21T19:22:57Z","closed_at":null,"body":"I've been using [Richard Berg's style guide](http://tfstoys.codeplex.com/SourceControl/changeset/view/33350#Modules/RichardBerg-Misc/Style.ps1) for normal powershell code.  It has helped a great deal in making my code more consistent, terse, idiomatic, and readable.  Pester tests are so different from normal powershell code that that style guide doesn't help a bit for Pester tests.  \r\n\r\nI've learned some pretty time-consuming lessons with Pester that probably could have been avoided with an opinionated style guide.  The main topics where I think I could have benefited from a strong opinion are as follows:\r\n\r\n* that multiple `Should`s in a single `It` block ought to be avoided\r\n* [how to deal with](https://stackoverflow.com/a/29087563/1404637) [powershell's unreliable module auto-loading](http://stackoverflow.com/q/28661852/1404637)\r\n* scope and repetition of code across Describe blocks\r\n* scope and variables in `-MockWith` script blocks\r\n* scope and variables in `-ParameterFilter` script blocks\r\n* when to start a new `Describe` block vs continuing an existing `Describe` block\r\n* how to deal with the material differences in `InModuleScope` scope behavior when running a `.Test.ps1` using `F5` from ISE vs `Invoke-Pester`\r\n* tradeoffs between using plain-but-repetitive clearly-readable code, and terse-but-error-prone code in `It` blocks\r\n* when to use `-Scope It` instead of a `Context` block when using `Assert-MockCalled`\r\n\r\nI'm sure someone with a greater corpus of tests has many more lessons learned that could be shared in a style guide. \r\n\r\nIs there a style guide for Pester tests?  If so where is it?  If not, is this project the right place to create one?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pester/Pester/issues/comments/94911772","html_url":"https://github.com/pester/Pester/issues/317#issuecomment-94911772","issue_url":"https://api.github.com/repos/pester/Pester/issues/317","id":94911772,"user":{"login":"dlwyatt","id":5107604,"avatar_url":"https://avatars.githubusercontent.com/u/5107604?v=3","gravatar_id":"","url":"https://api.github.com/users/dlwyatt","html_url":"https://github.com/dlwyatt","followers_url":"https://api.github.com/users/dlwyatt/followers","following_url":"https://api.github.com/users/dlwyatt/following{/other_user}","gists_url":"https://api.github.com/users/dlwyatt/gists{/gist_id}","starred_url":"https://api.github.com/users/dlwyatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlwyatt/subscriptions","organizations_url":"https://api.github.com/users/dlwyatt/orgs","repos_url":"https://api.github.com/users/dlwyatt/repos","events_url":"https://api.github.com/users/dlwyatt/events{/privacy}","received_events_url":"https://api.github.com/users/dlwyatt/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T19:22:57Z","updated_at":"2015-04-21T19:22:57Z","body":"I'm not sure where the \"Single Should per It\" guideline comes from.  I don't see a problem with multiple assertions, so long as they combine to test a single concept.  So, I might say that $variable should not be $null, then call a method on the $variable object, and compare the result to some expected value.  I'm fine with that being in the same It block.\r\n\r\nThat said, I think it's a cool idea, and we could put it on the wiki here."}}