-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Hi,
we are using the StaminaTestKit for our persist test. Our use case is only keep the latest version of persisted events. When we upgrade domain to new version with additional fields, the automatic generating test cannot pass easily.
e.g. ClassV1(field1) -> ClassV2(field1, field2) while field 1 and 2 are completely independent. the migration rule should be add field2 with default values which should be empty normally. That makes our test harder. if we use ClassV2 with empty field2 as sample to test, it should pass all the test but it will not test the field2 with data inside. if we use ClassV2 with random data in field2 as sample, it will break the test from V1 -> V2 while V2 test should be fine.
Currently, we just make a hacky approach by re-writing (mostly copy paste as most method inside is private which cannot be re-used easily) the StaminaTestKit. I mainly make generateRoundtripTestFor and generateStoredVersionsDeserializationTestsFor public so we can use them separately. Meanwhile, we change generateStoredVersionsDeserializationTestsFor to have additional field toVersion so we can decide the version range not always from version 1 to latest. By doing this, we can have ClassV2 with empty field2 sample for migration from V1 to V2 while another ClassV2 with data to check V2 only. If there are more fields in the future, we can test starting from V2 without changing anything before V2.
I believe this would make the test more flexible. Could you let me know what is your thought?
Thanks,
Yanyang