Commands Tests
def test_my_command(self):
self.craft("my_command", "arg1 arg2").assertSuccess()
This will programmatically run the command if it has been registered in your project and assert that no errors has been reported.
The following assertions are available when testing command with
craft
.Assert that command exited with code 0 meaning that it ran successfully.
self.craft("my_command").assertSuccess()
Assert command output has errors.
self.craft("my_command").assertHasErrors()
Assert command output contains the given string.
self.craft("my_command").assertOutputContains(output)
Assert command output to be exactly the same as the given reference output. Be careful to add eventual line endings characters when using this assertion method.
self.craft("my_command").assertExactOutput(output)
Assert command output does not contain the given reference output.
self.craft("my_command").assertOutputMissing(output)
Assert command output has exactly the given errors.
self.craft("my_command").assertExactErrors(errors)
Last modified 1yr ago