Empty-testing with Laravel

Uncategorized

Lately I have been using Laravel. It is a great PHP framework and will be the standard framework in any of my projects in years to come.

One important test to do before launching a solution is to test the application when there is more or less no data in the database. This is what I call empty-testing the application.

Using Laravel makes this task is quite trivial.

All database-tables are created using migrations. Your newly created database-tables are populated with the seeds command. While developing your application your database tables gets more and more data added and eventually you feel ready to launch. At this stage it is important to run one last test, and that is to remove all the bogus data you have added while developing the application.

With Laravel this is easy. All you need to do is running fresh migrations with the seeds parameter to first empty the database and then populate the database-tables with default and needed data.

Remember to take a backup of the running database before doing a fresh migration. This because the fresh migration will drop any tables in the database.

If you are a really experienced developer, you most likely have coded for potential no-data responses from the database. But even the best developers have forgotten to test one or two.

By following the procedure describe above each time you have corrected any flaws you have found during your empty-state-testing.

Note that it is just not errors and bugs you will discover while doing these tests. You will also experience what the application will look like when you hand it over to your client without much data present.

This can open up for the following questions:

Should there be a message or a “how to use this feature” in some views?

Should there be an icon telling the user something?

Did you forget to add more data to the database?

Perhaps the empty state could be used to teach the user how to use the application?