BCPNFR10 - Test Bicep File Naming
Module owners MUST name their test .bicep
files in the /tests/e2e/<defaults/waf-aligned/max/etc.>
directories: main.test.bicep
as the test framework (CI) relies upon this name.
Module owners MUST name their test .bicep
files in the /tests/e2e/<defaults/waf-aligned/max/etc.>
directories: main.test.bicep
as the test framework (CI) relies upon this name.
Module owners MUST use the below tooling for unit/linting/static/security analysis tests. These are also used in the AVM Compliance Tests.
Module owners MUST invoke the module in their test using the syntax:
module testDeployment '../../../main.bicep' =
Example 1: Working example with a single deployment
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
(...)
}
}
Example 2: Working example using a deployment loop
By default, the ReadMe-generating utility will create usage examples headers based on each e2e
folder’s name.
Module owners MAY provide a custom name & description by specifying the metadata blocks name
& description
in their main.test.bicep
test files.
For each test case in the e2e
folder, you can optionally add post-deployment Pester tests that are executed once the corresponding deployment completed and before the removal logic kicks in.
To leverage the feature you MUST:
Module owners MUST create the defaults
, waf-aligned
folders within their /tests/e2e/
directory in their resource module source code and SHOULD create a max
folder also. Module owners CAN create additional folders as required. Each folder will be used as described for various test cases.
Modules MUST use the prescribed tooling and testing frameworks defined in the language specific specs.
Modules MUST implement end-to-end (deployment) testing that create actual resources to validate that module deployments work. In Bicep tests are sourced from the directories in /tests/e2e
. In Terraform, these are in /examples
.
Each test MUST run and complete without user inputs successfully, for automation purposes.
Module owners MUST test that child and extension resources and those Bicep or Terreform interface resources that are supported by their modules, are validated in E2E tests as per SNFR2 to ensure they deploy and are configured correctly.
Modules SHOULD implement unit testing to ensure logic and conditions within parameters/variables/locals are performing correctly. These tests MUST pass before a module version can be published.
Unit Tests test specific module functionality, without deploying resources. Used on more complex modules. In Bicep and Terraform these live in tests/unit
.