I can see how that would work but it would only make sense when you have exactly one unit:test in a module, as unit:before/after is run for each test in the module.
Seems like it would be useful to have a way to perform a transaction within a unit test and then do assertions as a follow-on transaction. But of course that ends up just being a convenience as opposed to having single-test modules, which is not the end of the world. But if you could do that in a single unit test function context it starts to suggest that you could do it in a general XQuery processing context (similar to MarkLogic’s multi-transaction module extension to XQuery), but I have to assume that if that was a good idea the BaseX team would have already done it… Cheers, E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Andrew Sales <and...@andrewsales.com> Date: Tuesday, February 1, 2022 at 1:35 PM To: Eliot Kimber <eliot.kim...@servicenow.com> Cc: basex-talk@mailman.uni-konstanz.de <basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Techniques for Unit Testing Updating Operations [External Email] within a single unit:test function that itself performs an updating function there’s no way to then evaluate the result of the update as any asserts will be in the same transaction. That's where %unit:before and (more likely) %unit:after come in. You can't make the update and assertion within a single function, as you say, but the effective workaround is to do it after the fact, in a separate transaction. Andrew