Testing Charts

1. Running Chart Tests

Example: Run tests after install

helm install api ./chart -n web
helm test api -n web

2. Creating Test Pods

Example: HTTP smoke test

apiVersion: v1
kind: Pod
metadata:
  name: {{ include "myapp.fullname" . }}-test
  annotations:
    "helm.sh/hook": test
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
  restartPolicy: Never
  containers:
    - name: curl
      image: curlimages/curl:8.6.0
      command: ["sh", "-c"]
      args:
        - curl -fsS http://{{ include "myapp.fullname" . }}:{{ .Values.service.port }}/healthz

3. Using Test Annotations

AnnotationValue
helm.sh/hooktest (legacy test-success, test-failure removed)
helm.sh/hook-delete-policyhook-succeeded, hook-failed, before-hook-creation
helm.sh/hook-weightOrdering between multiple tests

4. Running Specific Tests

FlagUse
--filter name=test-connectionRun only matching test pods

5. Viewing Test Logs

FlagEffect
--logsStream pod logs to terminal after each test

6. Setting Test Timeout

FlagDefault
--timeout5m

7. Filtering Test Results

Example: Inspect failed test pod

kubectl logs -n web {{ include "myapp.fullname" . }}-test
kubectl describe pod -n web {{ include "myapp.fullname" . }}-test

8. Cleaning Test Pods

StrategyHow
AutoAnnotation hook-delete-policy: hook-succeeded
Manualkubectl delete pod -l app.kubernetes.io/instance=<release>

9. Testing with Different Values

Example: Per-env test matrix

for env in dev staging prod; do
  helm template ./chart -f values-$env.yaml | kubectl apply --dry-run=client -f -
done

10. Automating Chart Tests

ToolUse
chart-testing (ct)CI-grade lint + install + test on PR diff
helm-unittest pluginSnapshot-based unit tests for templates
GitHub Action helm/chart-testing-actionPre-built CI integration