2 hours ago · Tech · hide · 0 comments

Attempting to conjure good properties. Ever since I learned about property-based testing, I've been fascinated by it. The notion of test data generators seem superior to Test Data Builders: Both require some degree of test-specific boilerplate code, but you get more bang for your bob with test data generators. Instead of hard-coding some (often arbitrary) constant value in a Test Data Builder, you define a range of values that, one hopes, belong to the same equivalence class. Getting started with property-based testing isn't much more difficult than writing good unit tests with Test Data Builders. You can start with a simple unit test that exercises a single example, and fairly mechanically use test data generators to abstract away all the test code that doesn't really matter, but has to be there anyway. I've shown a comprehensive example in my article A restaurant example of refactoring from example-based to property-based testing. This process, however, may ultimately produce what…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.