![]() ![]() Each Context block covers if we use a parameter or not when calling the function.įinally, within each Context block is the It block describing the test and the expected result. Here we have a single Describe block for the Get-Something function, and within that block are two Context blocks. Take a look at a Describe block with Context and It blocks for testing the Get-Something function: This is very much like variable scoping in regular PowerShell code when dealing with if-then statements or loops. However, information defined in an It block will not be available to the parent Context or Describe blocks. A variable or other information defined in a Describe block will be available to any nested Context or It blocks. Just like describe, each block has its own scope. The It block is the actual test that you want to perform against the code. It blocks are the actual test and can be located under Describe or Context blocks. Context blocks are optional and just provide an additional group of It blocks within the Describe block. A Describe block can contain any number of Context and It blocks scoped to it. The Describe block contains a logical grouping of tests, and anything defined in that Describe block will no longer exist when it exits. There are six types of blocks we can use, and this article focuses on three:ĭescribe blocks are the highest level of organization in the Pester test file. Open up the 1 in your favorite editor and we’ll explore how tests are organized. With Pester installed and module code available, it’s time to write your first Pester test. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |