Semantic unit testing: test code without executing it
Published on: 2025-07-25 12:44:21
Semantic Unit Testing
April 09, 2025 · 18 mins · 3350 words
Left Wallapop a couple of weeks ago, heading to RevenueCat soon. In that classic ‘between jobs’ hacking window, I built suite: a Python library for semantic unit testing. What’s semantic unit testing? Think unit tests that understand context and meaning, not just assert obj == expected . Sound interesting? I’ll break down what semantic unit testing is, how suite works under the hood, and how you can integrate it.
What’s semantic unit testing?
Semantic unit testing is a testing approach that evaluates whether a function’s implementation aligns with its documented behavior. The code is analyzed using LLMs to assess if the implementation matches the expected behavior described in the docstring. It’s basically having an AI review your code and documentation together to spot discrepancies or bugs, without running the code.
This is, instead of writing classic unit tests with pairs of (input, output) , the testing responsibility
... Read full article.