High Testing

Test behavior, not implementation

Rule Description

Write tests that verify behavior, not internal implementation:
- Test public interfaces, not private methods
- Focus on inputs and outputs
- Tests should survive refactoring
- If implementation changes but behavior doesn't, tests should pass

```ruby
# Good: Test behavior
test "order total includes tax" do
order = Order.new(items: [Item.new(price: 100)])
assert_equal 108, order.total # 8% tax
end

# Bad: Test implementation
test "order calls calculate_tax method" do
order = Order.new(items: [Item.new(price: 100)])
assert order.instance_variable_get(:@tax_calculated)
end
```

Included in Rulesets

Jest Testing
24 rules • 2 standards
View
Maven Standards
23 rules • 0 standards
View
Travis CI Standards
22 rules • 0 standards
View
React Standards
28 rules • 1 standard
View
Next.js Patterns
28 rules • 1 standard
View
Code Review Standards
58 rules • 0 standards
View
GitHub Actions CI
22 rules • 0 standards
View
Mocha Testing
24 rules • 0 standards
View
Ruby Style Guide
25 rules • 1 standard
View
SQLite Standards
25 rules • 0 standards
View
Minitest Testing
24 rules • 1 standard
View
Express Standards
31 rules • 1 standard
View
C# Standards
21 rules • 1 standard
View
Go Best Practices
21 rules • 1 standard
View
Vitest Testing
24 rules • 3 standards
View
RSpec Testing
24 rules • 0 standards
View
pnpm Standards
23 rules • 3 standards
View
Poetry Standards
23 rules • 0 standards
View
MongoDB Best Practices
25 rules • 1 standard
View
Pylint Standards
22 rules • 0 standards
View
MySQL Standards
25 rules • 0 standards
View
Swift Guidelines
21 rules • 0 standards
View
FastAPI Guidelines
36 rules • 1 standard
View
uv Standards
25 rules • 2 standards
View
Rubocop Standards
21 rules • 1 standard
View
Documentation Standards
21 rules • 0 standards
View
PostgreSQL Standards
25 rules • 0 standards
View
npm Standards
23 rules • 2 standards
View
Redis Guidelines
25 rules • 0 standards
View
Gradle Standards
23 rules • 2 standards
View
CircleCI Standards
22 rules • 0 standards
View
Rails Standards
36 rules • 1 standard
View
Pytest Testing
24 rules • 2 standards
View
Laravel Guidelines
21 rules • 1 standard
View
GitLab CI Standards
22 rules • 0 standards
View
PHP Guidelines
21 rules • 1 standard
View
Java Standards
21 rules • 1 standard
View
Black Standards
22 rules • 0 standards
View
Rust Standards
21 rules • 1 standard
View
TypeScript Guide
28 rules • 4 standards
View
Yarn Standards
23 rules • 0 standards
View
Cargo Standards
23 rules • 2 standards
View
Kotlin Standards
21 rules • 1 standard
View
JavaScript Guide
28 rules • 2 standards
View
pip Standards
23 rules • 0 standards
View
Prettier Standards
21 rules • 0 standards
View
Django Best Practices
36 rules • 1 standard
View
Bundler Standards
23 rules • 1 standard
View
Composer Standards
23 rules • 1 standard
View
Git Workflow
21 rules • 0 standards
View
Vue Best Practices
28 rules • 1 standard
View
ESLint Standards
22 rules • 5 standards
View
Python Standards
33 rules • 2 standards
View
Spring Boot Standards
24 rules • 2 standards
View
Angular Guidelines
28 rules • 1 standard
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
High
Category
Testing
Used in
55 rulesets