Run
extends Command
in package
uses
Config
Executes tests.
Usage:
-
codecept run acceptance
: run all acceptance tests -
codecept run tests/acceptance/MyCest.php
: run only MyCest -
codecept run acceptance MyCest
: same as above -
codecept run acceptance MyCest:myTestInIt
: run one test from a Cest -
codecept run acceptance checkout.feature
: run feature-file -
codecept run acceptance -g slow
: run tests from slow group -
codecept run unit,functional
: run only unit and functional suites
Verbosity modes:
-
codecept run -v
: -
codecept run --steps
: print step-by-step execution -
codecept run -vv
: print steps and debug information -
codecept run --debug
: alias for-vv
-
codecept run -vvv
: print Codeception-internal debug information
Load config:
-
codecept run -c path/to/another/config
: from another dir -
codecept run -c another_config.yml
: from another config file
Override config values:
-
codecept run -o "settings: shuffle: true"
: enable shuffle -
codecept run -o "settings: lint: false"
: disable linting -
codecept run -o "reporters: report: \Custom\Reporter" --report
: use custom reporter
Run with specific extension
-
codecept run --ext Recorder
run with Recorder extension enabled -
codecept run --ext DotReporter
run with DotReporter printer -
codecept run --ext "My\Custom\Extension"
run with an extension loaded by class name
Full reference:
Arguments:
suite suite to be tested
test test to be run
Options:
-o, --override=OVERRIDE Override config values (multiple values allowed)
--config (-c) Use custom path for config
--report Show output in compact style
--html Generate html with results (default: "report.html")
--xml Generate JUnit XML Log (default: "report.xml")
--phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml")
--no-redirect Do not redirect to Composer-installed version in vendor/codeception
--tap Generate Tap Log (default: "report.tap.log")
--json Generate Json Log (default: "report.json")
--colors Use colors in output
--no-colors Force no colors in output (useful to override config file)
--silent Only outputs suite names and final results. Almost the same as `--quiet`
--steps Show steps in output
--debug (-d) Alias for `-vv`
--bootstrap Execute bootstrap script before the test
--coverage Run with code coverage (default: "coverage.serialized")
--coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
--coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
--coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
--coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
--coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
--no-exit Don't finish with exit code
--group (-g) Groups of tests to be executed (multiple values allowed)
--skip (-s) Skip selected suites (multiple values allowed)
--skip-group (-x) Skip selected groups (multiple values allowed)
--env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
--fail-fast (-f) Stop after first failure
--no-rebuild Do not rebuild actor classes on start
--help (-h) Display this help message.
--quiet (-q) Do not output any message. Almost the same as `--silent`
--verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
--seed Use the given seed for shuffling tests
Table of Contents
Constants
Properties
- $codecept : Codecept
- $defaultDescription : string|null
- $defaultName : string|null
- $executed : int
- $options : array<string|int, mixed>
- $output : OutputInterface
- $aliases : mixed
- $application : mixed
- $code : mixed
- $definition : mixed
- $description : mixed
- $fullDefinition : mixed
- $help : mixed
- $helperSet : mixed
- $hidden : mixed
- $ignoreValidationErrors : mixed
- $name : mixed
- $processTitle : mixed
- $synopsis : mixed
- $usages : mixed
Methods
- __construct() : mixed
- addArgument() : $this
- Adds an argument.
- addOption() : $this
- Adds an option.
- addUsage() : $this
- Add a command usage example, it'll be prefixed with the command name.
- complete() : void
- Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
- execute() : int|null|void
- Executes Run
- getAliases() : array<string|int, mixed>
- Returns the aliases for the command.
- getApplication() : Application|null
- Gets the application instance for this command.
- getDefaultDescription() : string|null
- getDefaultName() : string|null
- getDefinition() : InputDefinition
- Gets the InputDefinition attached to this Command.
- getDescription() : string
- Returns the description for the command.
- getHelp() : string
- Returns the help for the command.
- getHelper() : mixed
- Gets a helper instance by name.
- getHelperSet() : HelperSet|null
- Gets the helper set.
- getName() : string|null
- Returns the command name.
- getNativeDefinition() : InputDefinition
- Gets the InputDefinition to be used to create representations of this Command.
- getProcessedHelp() : string
- Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
- getSynopsis() : string
- Returns the synopsis for the command.
- getUsages() : array<string|int, mixed>
- Returns alternative usages of the command.
- ignoreValidationErrors() : mixed
- Ignores validation errors.
- isEnabled() : bool
- Checks whether the command is enabled or not in the current environment.
- isHidden() : bool
- run() : int
- Runs the command.
- setAliases() : $this
- Sets the aliases for the command.
- setApplication() : mixed
- setCode() : $this
- Sets the code to execute when running this command.
- setDefinition() : $this
- Sets an array of argument and option instances.
- setDescription() : $this
- Sets the description for the command.
- setHelp() : $this
- Sets the help for the command.
- setHelperSet() : mixed
- setHidden() : $this
- setName() : $this
- Sets the name of the command.
- setProcessTitle() : $this
- Sets the process title of the command.
- booleanOptions() : mixed
- configure() : mixed
- Sets Run arguments
- currentNamespace() : mixed
- enableExtensions() : mixed
- getGlobalConfig() : mixed
- getSuiteConfig() : mixed
- getSuites() : mixed
- initialize() : mixed
- Initializes the command after the input has been bound and before the input is validated.
- interact() : mixed
- Interacts with the user.
- matchSingleTest() : mixed
- matchTestFromFilename() : mixed
- overrideConfig() : mixed
- passedOptionKeys() : mixed
- runIncludedSuites() : mixed
- Runs included suites recursively
- runSuites() : mixed
- addRuntimeOptionsToCurrentConfig() : array<string|int, mixed>
- ensurePhpExtIsAvailable() : mixed
- isSuiteInMultiApplication() : bool
- isWildcardSuiteName() : bool
- matchFilteredTestName() : mixed
- validateName() : mixed
- Validates a command name.
Constants
FAILURE
public
mixed
FAILURE
= 1
INVALID
public
mixed
INVALID
= 2
SUCCESS
public
mixed
SUCCESS
= 0
Properties
$codecept
protected
Codecept
$codecept
$defaultDescription
protected
static string|null
$defaultDescription
The default command description
$defaultName
protected
static string|null
$defaultName
The default command name
$executed
protected
int
$executed
= 0
of executed suites
$options
protected
array<string|int, mixed>
$options
= []
of options (command run)
$output
protected
OutputInterface
$output
$aliases
private
mixed
$aliases
= []
$application
private
mixed
$application
$code
private
mixed
$code
$definition
private
mixed
$definition
$description
private
mixed
$description
= ''
$fullDefinition
private
mixed
$fullDefinition
$help
private
mixed
$help
= ''
$helperSet
private
mixed
$helperSet
$hidden
private
mixed
$hidden
= false
$ignoreValidationErrors
private
mixed
$ignoreValidationErrors
= false
$name
private
mixed
$name
$processTitle
private
mixed
$processTitle
$synopsis
private
mixed
$synopsis
= []
$usages
private
mixed
$usages
= []
Methods
__construct()
public
__construct([string|null $name = null ]) : mixed
Parameters
- $name : string|null = null
-
The name of the command; passing null means it must be set in configure()
Tags
addArgument()
Adds an argument.
public
addArgument(string $name[, int|null $mode = null ][, string $description = '' ][, mixed $default = null ]) : $this
Parameters
- $name : string
- $mode : int|null = null
-
The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
- $description : string = ''
- $default : mixed = null
-
The default value (for InputArgument::OPTIONAL mode only)
Tags
Return values
$thisaddOption()
Adds an option.
public
addOption(string $name[, string|array<string|int, mixed>|null $shortcut = null ][, int|null $mode = null ][, string $description = '' ][, mixed $default = null ]) : $this
Parameters
- $name : string
- $shortcut : string|array<string|int, mixed>|null = null
-
The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
- $mode : int|null = null
-
The option mode: One of the InputOption::VALUE_* constants
- $description : string = ''
- $default : mixed = null
-
The default value (must be null for InputOption::VALUE_NONE)
Tags
Return values
$thisaddUsage()
Add a command usage example, it'll be prefixed with the command name.
public
addUsage(string $usage) : $this
Parameters
- $usage : string
Return values
$thiscomplete()
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
public
complete(CompletionInput $input, CompletionSuggestions $suggestions) : void
Parameters
- $input : CompletionInput
- $suggestions : CompletionSuggestions
execute()
Executes Run
public
execute(InputInterface $input, OutputInterface $output) : int|null|void
Parameters
- $input : InputInterface
- $output : OutputInterface
Tags
Return values
int|null|voidgetAliases()
Returns the aliases for the command.
public
getAliases() : array<string|int, mixed>
Return values
array<string|int, mixed>getApplication()
Gets the application instance for this command.
public
getApplication() : Application|null
Return values
Application|nullgetDefaultDescription()
public
static getDefaultDescription() : string|null
Return values
string|nullgetDefaultName()
public
static getDefaultName() : string|null
Return values
string|nullgetDefinition()
Gets the InputDefinition attached to this Command.
public
getDefinition() : InputDefinition
Return values
InputDefinitiongetDescription()
Returns the description for the command.
public
getDescription() : string
Return values
stringgetHelp()
Returns the help for the command.
public
getHelp() : string
Return values
stringgetHelper()
Gets a helper instance by name.
public
getHelper(string $name) : mixed
Parameters
- $name : string
Tags
getHelperSet()
Gets the helper set.
public
getHelperSet() : HelperSet|null
Return values
HelperSet|nullgetName()
Returns the command name.
public
getName() : string|null
Return values
string|nullgetNativeDefinition()
Gets the InputDefinition to be used to create representations of this Command.
public
getNativeDefinition() : InputDefinition
Can be overridden to provide the original command representation when it would otherwise be changed by merging with the application InputDefinition.
This method is not part of public API and should not be used directly.
Return values
InputDefinitiongetProcessedHelp()
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
public
getProcessedHelp() : string
Return values
stringgetSynopsis()
Returns the synopsis for the command.
public
getSynopsis([bool $short = false ]) : string
Parameters
- $short : bool = false
-
Whether to show the short version of the synopsis (with options folded) or not
Return values
stringgetUsages()
Returns alternative usages of the command.
public
getUsages() : array<string|int, mixed>
Return values
array<string|int, mixed>ignoreValidationErrors()
Ignores validation errors.
public
ignoreValidationErrors() : mixed
This is mainly useful for the help command.
isEnabled()
Checks whether the command is enabled or not in the current environment.
public
isEnabled() : bool
Override this to check for x or y and return false if the command cannot run properly under the current conditions.
Return values
boolisHidden()
public
isHidden() : bool
Return values
bool —whether the command should be publicly shown or not
run()
Runs the command.
public
run(InputInterface $input, OutputInterface $output) : int
The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class.
Parameters
- $input : InputInterface
- $output : OutputInterface
Tags
Return values
int —The command exit code
setAliases()
Sets the aliases for the command.
public
setAliases(array<string|int, string> $aliases) : $this
Parameters
- $aliases : array<string|int, string>
-
An array of aliases for the command
Tags
Return values
$thissetApplication()
public
setApplication([Application|null $application = null ]) : mixed
Parameters
- $application : Application|null = null
setCode()
Sets the code to execute when running this command.
public
setCode(callable $code) : $this
If this method is used, it overrides the code defined in the execute() method.
Parameters
- $code : callable
-
A callable(InputInterface $input, OutputInterface $output)
Tags
Return values
$thissetDefinition()
Sets an array of argument and option instances.
public
setDefinition(array<string|int, mixed>|InputDefinition $definition) : $this
Parameters
- $definition : array<string|int, mixed>|InputDefinition
-
An array of argument and option instances or a definition instance
Return values
$thissetDescription()
Sets the description for the command.
public
setDescription(string $description) : $this
Parameters
- $description : string
Return values
$thissetHelp()
Sets the help for the command.
public
setHelp(string $help) : $this
Parameters
- $help : string
Return values
$thissetHelperSet()
public
setHelperSet(HelperSet $helperSet) : mixed
Parameters
- $helperSet : HelperSet
setHidden()
public
setHidden(bool $hidden) : $this
Parameters
- $hidden : bool
-
Whether or not the command should be hidden from the list of commands The default value will be true in Symfony 6.0
Tags
Return values
$thissetName()
Sets the name of the command.
public
setName(string $name) : $this
This method can set both the namespace and the name if you separate them by a colon (:)
$command->setName('foo:bar');
Parameters
- $name : string
Tags
Return values
$thissetProcessTitle()
Sets the process title of the command.
public
setProcessTitle(string $title) : $this
This feature should be used only when creating a long process command, like a daemon.
Parameters
- $title : string
Return values
$thisbooleanOptions()
protected
booleanOptions(InputInterface $input[, mixed $options = [] ]) : mixed
Parameters
- $input : InputInterface
- $options : mixed = []
configure()
Sets Run arguments
protected
configure() : mixed
Tags
currentNamespace()
protected
currentNamespace() : mixed
enableExtensions()
protected
enableExtensions(mixed $extensions) : mixed
Parameters
- $extensions : mixed
getGlobalConfig()
protected
getGlobalConfig([mixed $conf = null ]) : mixed
Parameters
- $conf : mixed = null
getSuiteConfig()
protected
getSuiteConfig(mixed $suite) : mixed
Parameters
- $suite : mixed
getSuites()
protected
getSuites([mixed $conf = null ]) : mixed
Parameters
- $conf : mixed = null
initialize()
Initializes the command after the input has been bound and before the input is validated.
protected
initialize(InputInterface $input, OutputInterface $output) : mixed
This is mainly useful when a lot of commands extends one main command where some things need to be initialized based on the input arguments and options.
Parameters
- $input : InputInterface
- $output : OutputInterface
Tags
interact()
Interacts with the user.
protected
interact(InputInterface $input, OutputInterface $output) : mixed
This method is executed before the InputDefinition is validated. This means that this is the only place where the command can interactively ask for values of missing required arguments.
Parameters
- $input : InputInterface
- $output : OutputInterface
matchSingleTest()
protected
matchSingleTest(mixed $suite, mixed $config) : mixed
Parameters
- $suite : mixed
- $config : mixed
matchTestFromFilename()
protected
matchTestFromFilename(mixed $filename, mixed $testsPath) : mixed
Parameters
- $filename : mixed
- $testsPath : mixed
overrideConfig()
protected
overrideConfig(mixed $configOptions) : mixed
Parameters
- $configOptions : mixed
passedOptionKeys()
protected
passedOptionKeys(InputInterface $input) : mixed
Parameters
- $input : InputInterface
runIncludedSuites()
Runs included suites recursively
protected
runIncludedSuites(array<string|int, mixed> $suites, string $parent_dir[, array<string, array<string|int, string>> $filterAppSuites = [] ][, array<string|int, string> $filterSuitesByWildcard = [] ]) : mixed
Parameters
- $suites : array<string|int, mixed>
- $parent_dir : string
- $filterAppSuites : array<string, array<string|int, string>> = []
-
An array keyed by included app name where values are suite names to run.
- $filterSuitesByWildcard : array<string|int, string> = []
-
A list of suite names (applies to all included apps)
runSuites()
protected
runSuites(mixed $suites[, mixed $skippedSuites = [] ]) : mixed
Parameters
- $suites : mixed
- $skippedSuites : mixed = []
addRuntimeOptionsToCurrentConfig()
private
addRuntimeOptionsToCurrentConfig(array<string|int, mixed> $config) : array<string|int, mixed>
Parameters
- $config : array<string|int, mixed>
Return values
array<string|int, mixed>ensurePhpExtIsAvailable()
private
ensurePhpExtIsAvailable(string $ext) : mixed
Parameters
- $ext : string
Tags
isSuiteInMultiApplication()
private
isSuiteInMultiApplication(string $suite_name) : bool
Parameters
- $suite_name : string
Return values
boolisWildcardSuiteName()
private
isWildcardSuiteName(string $suite_name) : bool
Parameters
- $suite_name : string
Return values
boolmatchFilteredTestName()
private
matchFilteredTestName(mixed &$path) : mixed
Parameters
- $path : mixed
validateName()
Validates a command name.
private
validateName(string $name) : mixed
It must be non-empty and parts can optionally be separated by ":".
Parameters
- $name : string