Skip to content

Entries with the tag “testing”

No, this isn’t a test or fake page. These “testing” blog entries are tagged so because they’re about unit, acceptance, smoke or any other types of software testing.

End to End Testing is Now Even More Important

I’ve been a huge fan of automated software testing for years. I tend to reach for unit tests over end-to-end (e2e) tests. This is probably because of two reasons: a focus on back-end work (primarily) and e2e testing was slow compared to my targeted unit tests.

With automated AI tooling now, though, I think the tide is changing. I still value my unit tests, but e2e is becoming my champion.

I’ll explain how and why my mind changed:

Sep 27, 2026 4 min read #ai #testing

Why I'm Starting to Love Parallel Testing

Maybe I’m behind. But I like to think of it as conservative. Parallel unit testing has been around for a while, and I haven’t really reached for it until recently.

This isn’t about not wanting to change, though. It’s about using the proper tools for the job, and only when necessary.

Or at least, that’s how I rationalize my delay. But maybe you’re in the same place. Let’s dig into why I waited, why you might want to wait still, and the reasons why this works now.

Sep 14, 2026 4 min read #laravel #php #phpunit #testing

Factory states can accept arguments

Most Eloquent factory states I’ve created are pretty simple like ->published() or ->cancelled(). They flip a flag or override a field to a fixed value making the call site of the factory easier to understand and requiring less ceremony. Awesome.

But, a state can also accept arguments, and that opens up some useful patterns like deriving values from another model passed in by the caller.

Aug 20, 2026 1 min read #laravel #testing

How to keep your tests off the real filesystem

Tests that read or write files can be really annoying. I’ll admit it, in the past I’ve skipped a few. I just hate having to think about seeding the files, cleaning them up after, and don’t get me started on the pollution left over when a test crashes before it can tear down.

Jul 23, 2026 2 min read #laravel #testing

Generating slugs in factories

Normally, I would generate a slug for an Eloquent model with an observer or an event. The creating event can verify if the slug field is filled, and if not, use the Str helper to add it to the current creation payload. Pretty cool.

Jul 1, 2024 1 min read #laravel #testing

The Importance of ToDo Tests

I’m not a huge fan of todo comments in code because I think they’re mainly forgotten. However, I don’t have the same opinion for PHPUnit tests. Let’s talk about why - and how to easily add them in your code.

Mar 22, 2021 4 min read #php #phpunit #testing

Do Not Calculate Answers to Your Unit Tests

Since you’re a programmer, you’re always looking for ways to be a bit more efficient. Because of this, it can be easy to fall into the trap of being too programatic, too calculation-heavy in your unit tests. But, this isn’t a test then - its just another block of quite fallible code. Let’s talk about why and show what to do instead.

Feb 8, 2021 3 min read #php #phpunit #testing

Stop Using Sqlite in Laravel Unit Tests

tldr; Using Sqlite in Laravel (or most PHP apps) for unit testing causes false positives in unit tests. Things that work will not work when you move to production and use a different db like MySQL. Instead, spin up a test database that is the same tech and engine as your application will be.

Nov 6, 2019 8 min read #php #testing

Mark WIP Features for Better UX/Customer Acceptance

When you’re trying to demo your work in progress to a client, it can be difficult to know where to draw the line between working and non-working features. On one hand, you want to show them some context so they can understand the current feature. But, then what happens when they invariably try to explore the context (which may not be done)? Let me put that in a more concrete example.

Aug 22, 2019 3 min read #javascript #misc-web #testing

PHPUnit Runs Data Provider Before Setup

I started noticing a disturbing trend on one of my projects: developers were doing too much logic in the setup and data provider methods of their PHPUnit tests. However, before we could address this, a “limitation” popped up which helped them kick this habit.

Dec 3, 2018 1 min read #php #phpunit #testing

Better failing tests with Mockery::on()

In an earlier post titled Use $this->fail() with Mockery::on(), I explained the challenges of debugging a failing test with the closure passed to Mockery::on(). Instead of returning false, I opted to use $this->fail() - which seemed like a good idea at the time. After all, I was doing my test, then failing with a useful bit of information. (Previous to this, it would just say that you don’t have a matching handler for this assertion, which was really confusing).

Oct 15, 2018 1 min read #mockery #php #testing

Use Dependency Injection in Laravel Console Commands

It’s important to unit test your application code - even your console commands. So many times, I’ve seen people using the Artisan facade inside of console commands to either queue up new commands or call a different command. This makes it more difficult to unit test the application - you have to rely more on fakery (requiring you to reset your application each time then) and/or integration tests.

Sep 23, 2017 2 min read #laravel #php #testing

Use the $this->fail() method with Mockery::on()

When you have a more complex assertion you need to make on the parameters of a mocked object, you might use the Mockery::on() method. It can be hard to tell how this fails, though, because if the assertion fails somewhere, the message is confusing - it basically says that there was no matching call to that method, which is technically correct.

Jun 11, 2017 2 min read #mockery #php #testing

Use Anonymous Classes to Test Traits

I’m guilty of creating stub-like classes in my tests to unit test traits, sometimes. So, you end up with a special class inside your unit test file, perhaps at the bottom, that is empty but only extends the trait or something like that. This is not a good idea, but it was my only way that I could figure out how to unit-test traits separately - especially if they were made of protected methods.

May 11, 2017 3 min read #php #phpunit #testing

Using Developer Tools in Chrome for Testing

In a perfect world, when testing your website you’d have a giant device library, a number of different internet connection speeds, and a bunch of users using the system simultaneously. A perfect world? Pfffft. But, I can help you at least get close to this set of requirements for your test. Let’s see how we can use Google Chrome to simulate different devices and change our internet connection speeds.

May 25, 2016 4 min read #misc-web #testing

Testing Error 500 Pages in Zend Framework

For the most part, ZF can capture any of your hard errors. It will generate an error 500. You’ve seen them, don’t lie… I’ve seen them way too many times. However, in my production application, I capture these with a specific controller. And because I love Unit Testing, I want to make sure that I test my implementation of my omg-this-is-broken setup.

Jul 3, 2012 1 min read #phpunit #testing #zend-framework

Extend Zend_Mail to use Views

I love working in the Zend Framework view system. One thing that bothers me, however, is that I must create a complex set of models when trying to send email. I decided that I’d like to move all of this output for the mail class into my own view system as well.

Mar 20, 2012 4 min read #testing #zend-framework

When Writing Unit Tests, Test Against Absolutes

So, while chatting with one of the developers on my team, we started talking about testing an XML document creation process he had been working on. He wrote a unit test and said “see, here is my class which generates the XML, and then here I use DomDocument to add the nodes I know it will have and test against that.”

Feb 14, 2012 1 min read #testing

Testing Outgoing Email with Zend Framework

I was creating a new application with Zend Framework at work the other day and I started using my technique that I described here by adding the original email in my email address using the + sign. However, the current organization I’m at has a mailserver (Exchange?) that is either configured not to allow this or just doesn’t have this functionality built in. So, this won’t work. I solved this with a new implementation of the mail class.

Jul 27, 2011 2 min read #testing #zend-framework

APD post processing wrapper

A while ago, I discovered the ‘joys’ of APD… and then more so, the ‘joys’ of not being able to make heads or tails out of the output script. After digging deeper, I saw that the original directory already had some PHP scripts to parse the output. I ran those and wasn’t very impressed. Even more important, my boss wouldn’t be impressed. I needed to be able to make something that could be useful to integrate into a table (I finally used dojo to create a table…)

Nov 17, 2007 1 min read #performance #php #testing