# info > App::Prove::State

---
type: CommandReference
command: App::Prove::State
mode: perldoc
section: 3perl
source: perldoc
---

## Quick Reference

- `prove --state=failed,save -rbv` — re-run failed tests and save state
- `prove --state=last,save` — run in same order as last time
- `prove --state=hot,save` — run most recently failed tests first
- `prove --state=slow,save` — run tests slowest to fastest
- `prove --state=fast,save` — run tests fastest to slowest
- `prove --state=new,save` — run tests newest to oldest
- `prove --state=old,save` — run tests oldest to newest
- `prove --state=all,save` — run all tests in normal order

## Name

App::Prove::State - State storage for the "prove" command.

## Synopsis

shell
# Re-run failed tests
$ prove --state=failed,save -rbv
perl
use App::Prove::State;
my $state = App::Prove::State->new(
    store      => 'state_file',
    extensions => ['.t'],
    result_class => 'App::Prove::State::Result',
);
$state->apply_switch('failed,save');
$state->commit;
## Methods

### Class Methods

- `new(store => $filename, extensions => \@extensions, result_class => $class)` — constructor. `store` is required; `extensions` defaults to `['.t']`; `result_class` defaults to `App::Prove::State::Result`.
- `result_class` — getter/setter for the class used to track test results. Must subclass `App::Prove::State::Result` or provide identical interface.
- `extensions` — get or set list of file extensions considered tests. Defaults to `['.t']`.
- `results` — get the results of the last test run. Returns a `result_class()` instance.
- `commit` — save the test results. Should be called after all tests have run.

### Instance Methods

- `apply_switch($string)` — apply a list of state options (e.g., `'failed,save'`). Updates internal state. Diagnoses: `Illegal state option: %s`.
- `last` — run in same order as last time.
- `failed` — run only failed tests from last time.
- `passed` — run only passed tests from last time.
- `all` — run all tests in normal order.
- `hot` — run tests that most recently failed first.
- `todo` — run tests ordered by number of todos.
- `slow` — run tests slowest to fastest.
- `fast` — run tests fastest to slowest.
- `new` — run tests newest to oldest.
- `old` — run tests oldest to newest.
- `save` — save state on exit.
- `get_tests(@args)` — given a list of args, get the names of tests that should run.
- `observe_test($test)` — store the results of a test.
- `save` — write the state to a file.
- `load` — load the state from a file.

## Examples

shell
# Run only failed tests from previous run, save state
$ prove --state=failed,save -rbv

# Run in same order as last run, save
$ prove --state=last,save -rbv

# Run fastest tests first
$ prove --state=fast,save -rbv
## See Also

- [App::Prove](http://localhost/phpMan.php/perldoc/App%3A%3AProve)
- [App::Prove::State::Result](http://localhost/phpMan.php/perldoc/App%3A%3AProve%3A%3AState%3A%3AResult)