Performance: Feature tests
MEDIUM IMPACT
Feature tests impact the overall development feedback loop and CI/CD pipeline speed, affecting how quickly developers can detect issues and deploy.
public function testUserCanCreatePost() {
$postService = $this->mock(PostService::class);
$postService->shouldReceive('create')->once()->andReturn(new Post(['title' => 'Test']));
$user = User::factory()->make();
$this->actingAs($user);
$response = $this->post('/posts', ['title' => 'Test', 'body' => 'Content']);
$response->assertStatus(201);
}public function testUserCanCreatePost() {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->post('/posts', ['title' => 'Test', 'body' => 'Content']);
$response->assertStatus(201);
$this->assertDatabaseHas('posts', ['title' => 'Test']);
}| Pattern | Database Calls | External Requests | Test Runtime | Verdict |
|---|---|---|---|---|
| Full HTTP request with DB | Multiple | None or some | High (200-500ms+) | [X] Bad |
| Mocked services, no DB | None | None | Low (50-150ms) | [OK] Good |