Masonite Documentation
Masonite Repository
Search…
v4.0
Introduction and Installation
Prologue
Creating A Blog Tutorial
Release Cycle
Contributing Guide
How To Contribute
The Basics
Routing
Controllers
Middleware
Response
Request
Static Files
Views
Environments
Configuration
Error Handling
Features
API Development
Authentication
Authorization
Broadcasting
Caching
Compiling Assets
Commands
CSRF Protection
Events
Facades
Filesystem and Uploading
Hash ID's
Helpers
Mail
Notifications
Package Development
Queues and Jobs
Rate Limiting
Sessions
Task Scheduling
Tinker Shell (REPL)
Validation
Architecture
Service Providers
Service Container
Security
CORS
Masonite ORM
To Masonite ORM Docs
Testing
Getting Started
HTTP Tests
Database Tests
Commands Tests
Console Tests
Mocking
Extending
Official Packages
Masonite Debugbar
How-to Guides
Build Email Verification from Scratch With Masonite Framework and JSON Web Tokens
Deploying a Masonite Application to Heroku
How To Deploy Masonite to PythonAnywhere
How-To: Use RabbitMQ with Masonite 2.0 queues
How To Use The Repository Pattern with Masonite
Making Masonite and Laravel Mix work together
What's New
Masonite 1.3
Masonite 1.4
Masonite 1.5
Masonite 1.6
Masonite 2.0
Masonite 2.1
Masonite 2.2
Masonite 2.3
Masonite 3.0
Upgrade Guide
Masonite 1.3 to 1.4
Masonite 1.4 to 1.5
Masonite 1.5 to 1.6
Masonite 1.6 to 2.0
Masonite 2.0 to 2.1
Masonite 2.1 to 2.2
Masonite 2.2 to 2.3
Masonite 2.3 to 3.0
Masonite 3.0 to 4.0
Powered By
GitBook
Commands Tests
You can test your
custom commands
running in console with
craft
test helper.
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.
Available Assertions
The following assertions are available when testing command with
craft
.
​
assertSuccess
​
​
assertHasErrors
​
​
assertOutputContains
​
​
assertExactOutput
​
​
assertOutputMissing
​
​
assertExactErrors
​
assertSuccess
Assert that command exited with code 0 meaning that it ran successfully.
self
.
craft
(
"my_command"
).
assertSuccess
()
assertHasErrors
Assert command output has errors.
self
.
craft
(
"my_command"
).
assertHasErrors
()
assertOutputContains
Assert command output contains the given string.
self
.
craft
(
"my_command"
).
assertOutputContains
(
output
)
assertExactOutput
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
)
assertOutputMissing
Assert command output does not contain the given reference output.
self
.
craft
(
"my_command"
).
assertOutputMissing
(
output
)
assertExactErrors
Assert command output has exactly the given errors.
self
.
craft
(
"my_command"
).
assertExactErrors
(
errors
)
Testing - Previous
Database Tests
Next - Testing
Console Tests
Last modified
3mo ago
Export as PDF
Copy link
Outline
Available Assertions