benchpress/BenchPress
Caroline Quigg 4f4a940696
Basic unit tests for Generator project (#324)
* Add unit test project for Generator solution
2023-04-14 12:31:05 -07:00
..
Generators Parameter and Variable Resolution (#323) 2023-04-14 10:13:44 -07:00
Generators.Tests Basic unit tests for Generator project (#324) 2023-04-14 12:31:05 -07:00
bicep@d6f8b33a8a update bicep submodule to latest commit 2022-12-08 18:12:30 +00:00
BenchPress.sln Basic unit tests for Generator project (#324) 2023-04-14 12:31:05 -07:00
README.md README for Generator (#276) 2023-03-29 11:33:42 -07:00

README.md

Generator

The Generator project can take a .bicep file and scaffold example Pester tests that use the BenchPress PowerShell module. These generated tests are not meant to work out of the box and are just a starting point for your infrastructure tests. Tests will only be generated for supported Azure resources. You can see which resources are currently supported by the classes defined in the Generators\ResourceTypes folder. The Generator project is still in the early stages of development, so expect many ongoing changes.

Running Locally

If you are interested in contributing to or consuming the Generator project at this time, the following steps will help you get started:

Prerequisites

Steps

  1. Clone the repository.

  2. Open your command prompt and initialize the bicep submodule:

     git submodule update --init --recursive
    
  3. Navigate to the BenchPress solution:

     cd BenchPress
    
  4. Build the solution:

     dotnet build
    
  5. Run the Generator project using a .bicep file

    cd Generators
    dotnet run --provider powershell --import ../../examples.StreamAnalytics/streamAnalytics.bicep --output ./output/
    
    • The provider option specifies the language test file to generate. Currently, only PowerShell is supported.
    • The import option specifies the .bicep file to generate tests for. Feel free to use your own. This document uses an existing .bicep file that is located under the examples directory.
    • The output option specifies where to write the generated test files. Feel free to use a different path.
  6. Success! The generated PowerShell test files will be located in the directory specified by the output option. Open these test files and look over the contents to see the tests that have been generated. You will notice that you will still need to edit some of the file contents (i.e. changing resource names) to make these tests work. Happy testing!