Based on the comments of the question, I am answering my own question, so this may help others, looking for similar solution.
After all we did skip asserting generated IDs, as they were not really interesting for us. What we actually did want to check is that the entries between main
and related
tables are "properly linked". To achieve this, in our unit test we did created the the dataset using query, joining both tables:
SELECT main.comment, related.comment AS related_comment
FROM main, related
WHERE main.id = related.main_id
Then we assert, that dataset produced by this query matches statically defined dataset:
<dataset>
<result comment="ABC" related_comment="#1 related to ABC" />
<result comment="ABC" related_comment="#2 related to ABC" />
<result comment="DEF" related_comment="#3 related to DEF" />
<result comment="DEF" related_comment="#4 related to DEF" />
</dataset>
When the datasets are matching, we can assume, that entries were "linked properly".