Posts List

Use Randomness Intentionally in Testing

Randomness can serve a useful purpose in factories, seeders, and tests. There are times it can cause issues though. Here are some rules I think about when introducing randomness into a test.

Todo Tests Are Not Cheating

Why would you ever mark a test as todo? Isn’t that devaluing your tests? Not at all! I’ll share some ways I use todo tests effectively.

Laravel 8 Factory Relationships

A couple days ago, I walked through a few potential gotchas with relationships in Laravel factories. Let’s see how it works in Laravel 8.

Understanding Relationships in Laravel Factories

What’s the best way to define a relationship in your Laravel factories? I’ll share some tips that will help you avoid some common pitfalls, as well as give you a deeper insight into how factories work.

One More Primary Key Example

Let’s wrap up this series of tips, and show one final example when setting an explicit primary key value can improve the quality of your tests.

Another Use Case for Explicit Primary Key Values

Yesterday I shared an example where setting explicit primary key values in your tests can make your tests more reliable. Let’s take a look at another example.

Testing Strategy: When to Use Explicit Primary Key Values

Based on the projects I’ve seen over the years, it’s a bit unusual to set an explicit primary key value when arranging the database state for a feature test. I’d like to share a few times when this strategy can make your tests more reliable.