Medium
Testing
Integration tests over unit tests for web apps
Official
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
RSpec Testing
24 rules • 0 standards
Jest Testing
24 rules • 2 standards
Pytest Testing
24 rules • 2 standards
Vitest Testing
24 rules • 3 standards
Mocha Testing
24 rules • 0 standards
Code Review Standards
58 rules • 0 standards
Add This Rule
Sign in to add this rule to your workspace
Sign in with GitHubDetails
- Severity
- Medium
- Category
- Testing
- Used in
- 7 rulesets