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
Console Tests
You can test what has been output to standard console during Masonite unit tests thanks to useful console assertions.
Output here is the standard output often named
stdout
. Error here is the standard error often named
stderr
.
External packages, prints in your code can output content in console (as output or error).
If you want to assert content output by a Masonite command you should use
Commands Tests
assertions instead.
Available Assertions
The following assertions are available:
​
assertConsoleEmpty
​
​
assertConsoleNotEmpty
​
​
assertConsoleExactOutput
​
​
assertConsoleOutputContains
​
​
assertConsoleOutputMissing
​
​
assertConsoleHasErrors
​
​
assertConsoleExactError
​
​
assertConsoleErrorContains
​
assertConsoleEmpty
Assert that nothing has been printed to the console.
assertConsoleNotEmpty
Assert that something has been printed to the console (output or error).
assertConsoleExactOutput
Assert that console standard output is equal to given output.
print
(
"Success !"
)
self
.
assertConsoleExactOutput
(
"Success !\n"
)
assertConsoleOutputContains
Assert that console standard output contains given output.
print
(
"Success !"
)
self
.
assertConsoleOutputContains
(
"Success"
)
assertConsoleOutputMissing
Assert that console standard output does not contain the given output.
print
(
"Success !"
)
self
.
assertConsoleOutputMissing
(
"hello"
)
assertConsoleHasErrors
Assert that something has been output to console standard error.
assertConsoleExactError
Assert that console standard error is equal to given error.
print
(
"An error occured !"
,
file
=
sys
.
stderr
)
self
.
assertConsoleExactError
(
"An error occured !\n"
)
assertConsoleErrorContains
Assert that console standard error contains given error.
print
(
"An error occured !"
,
file
=
sys
.
stderr
)
self
.
assertConsoleErrorContains
(
"error"
)
Testing - Previous
Commands Tests
Next - Testing
Mocking
Last modified
3mo ago
Export as PDF
Copy link
Outline
Available Assertions