--- title: Unit Testing for Rules sort_rank: 6 --- # Unit Testing for Rules You can use `promtool` to test your rules. ```shell # For a single test file. ./promtool test rules test.yml # If you have multiple test files, say test1.yml,test2.yml,test2.yml ./promtool test rules test1.yml test2.yml test3.yml ``` ## Test file format ```yaml # This is a list of rule files to consider for testing. Globs are supported. rule_files: [ - ] # optional, default = 1m evaluation_interval: # The order in which group names are listed below will be the order of evaluation of # rule groups (at a given evaluation time). The order is guaranteed only for the groups mentioned below. # All the groups need not be mentioned below. group_eval_order: [ - ] # All the tests are listed here. tests: [ - ] ``` ### `` ``` yaml # Series data interval: input_series: [ - ] # Unit tests for the above data. # Unit tests for alerting rules. We consider the alerting rules from the input file. alert_rule_test: [ - ] # Unit tests PromQL expressions. promql_expr_test: [ - ] ``` ### `` ```yaml # This follows the usual series notation '{