Posts tagged with testing

Implementing event sourcing: testing aggregates

by Freek Van der Herten – 4 minute read

Earlier this year we released v2 of laravel-event-sourcing. This package is probably the easiest way to getting started with event sourcing in Laravel. A significant feature of v2 was the addition of aggregates.

Today we released another new version of the package that adds test methods. These methods allow you to verify if the aggregate behaves correctly. In this post, I'll show you an example and explain how the test methods are implemented.

These test methods were inspired by the awesome testing methods Frank De Jonge made in his Eventsauce package.

Read more

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Start testing your Laravel applications

jasonmccreary.me

Jason McCreary wrote an epic blogpost on how to get started with tests in a Laravel app. I wish I could have read this when I started out with testing.

This brings me to the next common response, we don’t know where to start testing. This comes in two forms. The first form is quite literally we don’t know which test to write first. The second form is more not knowing how to write the first test. ... Today, I want to focus on getting started with testing your Laravel applications.

Read more [jasonmccreary.me]

The case of the Laravel TestCase

timacdonald.me

Tim MacDonald, a freelance software developer based in Sydney, investigates how to make Laravel tests run faster. Turns out you a lot can be gained by caching the config.

I saw a conversation on Twitter the other day discussing how Laravel was slowing down a test suite. I decided I wanted to dig into this and see if there was anything to it.

Read more [timacdonald.me]

A package to control the flow of time

by Freek Van der Herten – 2 minute read

Imagine you're building that your app can notify your user, but you don't want to send more than one notification in a timeframe of five seconds. How are you going to test the time aspect? Do you have to create a test that takes five minutes?

Read more

Your first performance budget with Lighthouse

bitsofco.de

Ire Aderinokun, Front-End Developer and User Interface Designer, explains how you can Lighthouse in CI.

Until recently, I also hadn't setup an official performance budget and enforced it. This isn’t to say that I never did performance audits. I frequently use tools like PageSpeed Insights and take the feedback to make improvements. But what I had never done was set a list of metrics that I needed the site to meet, and enforce them using some automated tool.

Read more [bitsofco.de]

Tests and types

stitcher.io

My colleague Brent wrote another excellent blog post, this time on tests and types.

So while strong types can help us to ensure program correctness, some tests will always be a necessity to ensure business correctness. It's a matter of "both and", not "either or".

Read more [stitcher.io]

Tidying Up Your PHPUnit Tests with Data Providers

tighten.co

Over at the Tighten blog, Chris Trombley published a new post on how to use data providers in PHPUnit.

PHPUnit gives us a way to consolidate this common logic while varying our setup data, without losing the benefit of dedicated, smaller test methods. In this post, we'll explore PHPUnit's data providers. While data providers are available in any PHPUnit test suite, let's look at how they can help us tidy up our tests in a Laravel application.

Read more [tighten.co]

20 lines of code that will beat A/B testing every time

stevehanov.ca

In an older but still post, Steve Hanov explains a nice algorithm to test out new features on your audience. I don't now if this approach will yield better results, but it sure is an interesting idea.

In recent years, hundreds of the brightest minds of modern civilization have been hard at work not curing cancer. Instead, they have been refining techniques for getting you and me to click on banner ads. It has been working. Both Google and Microsoft are focusing on using more information about visitors to predict what to show them. Strangely, anything better than A/B testing is absent from mainstream tools, including Google Analytics, and Google Website optimizer. I hope to change that by raising awareness about better techniques.

Read more [stevehanov.ca]

How migrations might be slowing down your Laravel tests

alexvanderbist.com

Having a lot of migrations might slow down your tests. My colleague Alex shares how you can fix this.

One of the larger test suites I run daily has about 1500 tests in it. It takes just over 4 minutes to complete at an average of 160ms per test. That's pretty good. However, lately I've noticed a delay between starting PHPUnit and running the first test. This delay grew to the point where running a single test would take almost 12 seconds with the setUp method using most of that time on... migrations.

Read more [alexvanderbist.com]

Tips to Speed up Your Phpunit Tests

laravel-news.com

On the Laravel News blog, Tim MacDonald wrote a nice collection of tips on how to make PHPUnit tests run faster.

Having a fast test suite can be just as important as having a fast application. As a developer, getting feedback quickly about the state of your code allows for a much quicker development turnaround. Here we are going to run through some tips you can implement today to make your tests run faster.

Read more [laravel-news.com]

laravel-backup v6 has been released

by Freek Van der Herten – 4 minute read

laravel-backup is a Laravel package that can backup your application. It can create a zip containing a dump of your database together with other files that you can select. Using the power of Laravel's filesystem abstraction this zip can than be uploaded to one or more remote filesystems. The package…

Read more