How Tests Calcify Applications at Different Levels

Tests tend to make your code more resistant to change and refactoring. There are things you can do to alleviate this, but at the cost of complexity in the test code (or experience in the developer.)

See: Tests are Great Calcifiers.

This is true of tests at all levels — unit, api, ui automation.

However, it’s actually inversely costly.

Unit tests, which are the easiest to write, and most focused, are most often tightly coupled to the implementation — and makes refactoring without ignoring or rewriting tests harder.

API tests are usually very tightly coupled to the API, making it resistant to change, but also can be easier to refactor or replace along with the API code.

UI tests can be tightly tied to the implementation, but patterns like page objects and user actions allow loose coupling between the tests and the implementation. However, it takes knowledgable and experienced developers to write loosely coupled UI tests.

So it turns out that the cost of tests — and their likelihood of being tightly coupled to the production code — at least as it relates to the risk of calcifying your application, are greater at the lower level, and lesser at higher levels.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s