Is there a programming language that is testable by design or at least exhibit very good properties in terms of testability?
For instance, a programming language designed so that unit testing is a non-optional part of the coding process, or, better yet, a programming language where the program is more or less inferred from the unit tests.
Or if you prefer twisting the question a bit, what imperative programming is bad practice or unnecessary to ensure testability?
What about object-oriented programming? Things like dependency injection and mocking libraries really helped TDD, wouldn’t these practices benefit from being part the language design? I’ve been looking around and languages with rich meta models tend to permit very DSL-like APIs to be written in the target language. These libraries are being built on top of that, why not pull these things into the language itself?
I find that that blog post referenced by James Black has a really good point to it.
Not long ago, I reflected on my
testing habits for the past ten years,
and I made a couple of interesting
observations:
- I feel the need to write tests for the code that I write very often.
- Just as often, that need is thwarted by environmental constraints, so I end
up not writing these tests.
Do you agree with the statement that dynamic programming languages make writing tests easier?
Google is working on noop as a language (OOP, Java-based) created to produce code that is always testable.
The language also explicitly forbids certain constructs that make it harder to test code, like for instance statics.