2019-05-21 15:50:36 -07:00
< small > *[documentation ](/README.md#documentation ) / Testing Policies*</ small >
2019-05-21 11:06:03 -07:00
# Testing Policies
2020-02-06 00:04:19 -08:00
2019-05-22 18:14:10 +03:00
The resources definitions for testing are located in [/test ](/test ) directory. Each test contains a pair of files: one is the resource definition, and the second is the kyverno policy for this definition.
2019-05-21 15:50:36 -07:00
## Test using kubectl
2020-02-06 00:04:19 -08:00
2019-05-22 18:14:10 +03:00
To do this you should [install kyverno to the cluster ](/documentation/installation.md ).
For example, to test the simplest kyverno policy for ConfigMap, create the policy and then the resource itself via kubectl:
2019-05-22 20:41:33 -07:00
2019-05-22 18:14:10 +03:00
````bash
cd test/ConfigMap
kubectl create -f policy-CM.yaml
kubectl create -f CM.yaml
````
Then compare the original resource definition in CM.yaml with the actual one:
2019-05-22 20:41:33 -07:00
2019-05-22 18:14:10 +03:00
````bash
kubectl get -f CM.yaml -o yaml
````
2020-02-07 12:33:57 -08:00
2020-02-19 18:50:03 -08:00
## Test using Kyverno CLI
The Kyverno CLI allows testing policies before they are applied to a cluster. It is documented at [Kyverno CLI ](kyverno-cli.md )
2020-02-07 12:33:57 -08:00
< small > *Read Next >> [Policy Violations ](/documentation/policy-violations.md )*</ small >