Medium Testing

Integration tests over unit tests for web apps

Rule Description

For web applications, prefer integration/request tests over isolated unit tests:
- Test the full request/response cycle
- Catch issues with middleware, routing, authentication
- More confidence that the feature actually works

```ruby
# Good: Integration test
test "user can create a post" do
sign_in users(:alice)
post posts_path, params: { post: { title: "Hello", body: "World" } }
assert_redirected_to post_path(Post.last)
assert_equal "Hello", Post.last.title
end

# Unit tests are still valuable for:
# - Complex business logic
# - Edge cases
# - Performance-critical code
```

Included in Rulesets

Minitest Testing
24 rules • 1 standard
View
RSpec Testing
24 rules • 0 standards
View
Jest Testing
24 rules • 2 standards
View
Pytest Testing
24 rules • 2 standards
View
Vitest Testing
24 rules • 3 standards
View
Mocha Testing
24 rules • 0 standards
View
Code Review Standards
58 rules • 0 standards
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
Medium
Category
Testing
Used in
7 rulesets