2019-05-21 22:50:36 +00:00
< small > *[documentation](/README.md#documentation) / Testing Policies*< / small >
2019-05-21 18:06:03 +00:00
# Testing Policies
2020-02-06 08:04:19 +00:00
2019-05-22 15:14:10 +00: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 22:50:36 +00:00
## Test using kubectl
2020-02-06 08:04:19 +00:00
2019-05-22 15:14:10 +00: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-23 03:41:33 +00:00
2019-05-22 15:14:10 +00: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-23 03:41:33 +00:00
2019-05-22 15:14:10 +00:00
````bash
kubectl get -f CM.yaml -o yaml
````
2020-02-07 20:33:57 +00:00
2020-02-20 02:50:03 +00: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 20:33:57 +00:00
< small > *Read Next >> [Policy Violations ](/documentation/policy-violations.md )*</ small >