Symmetric Properties
Explore the concept of symmetric properties in property-based testing. Understand how reversible operations like encoding and decoding can be tested together by verifying that applying both returns original data. Learn about combining symmetric properties with invariants for comprehensive test coverage in PropEr with Erlang.
We'll cover the following...
We'll cover the following...
What are symmetric properties?
From time to time, we may find it difficult to discern what components depend on each other to succeed. Two bits of code may perform opposite actions, such as an encoder and a decoder. We need the encoder to test the decoder, and the decoder to test the encoder. In other cases, we may have a chain of operations that could be made reversible:
- Editing text and undoing changes.
- Translating the text from French to English to Spanish and back to French.
- Passing a message across multiple servers until it’s back to its original server.
- Allowing a character in a game to walk in every direction until it makes its way back to its origin.