Dear all,
I have not found a way to make basex unit module to test updating functions. I have a function site:add-movies which results in several db:add instructions. I try to achieve something like:
declare %unit:test %updating function test-site:download-movies() { let $result := site:add-movies( $test-site:site-db, test-site:fake-fetch-file#1, 7 ) return unit:assert-equals(1, 1) (: here I am going to check if db contains expected elements :) };
But let command is not valid for updating expression. Basex docs mention something about update:output and update:cache which may be of some use here but no exhaustive example is given for.
Anyone had similar problem?
BR
Dear BR dudzikp,
You can place your actual test your assertion in a second function with the %unit:after annotation. Another solution is to perform your update in a %unit:before function and test the result in the main function. See [1] for an example.
Cheers, CG
[1] https://docs.basex.org/wiki/Unit_Module#unit:before
On Tue, Nov 17, 2020 at 1:20 PM dudzikp@yahoo.com dudzikp@yahoo.com wrote:
Dear all,
I have not found a way to make basex unit module to test updating functions. I have a function site:add-movies which results in several db:add instructions. I try to achieve something like:
declare %unit:test %updating function test-site:download-movies() { let $result := site:add-movies( $test-site:site-db, test-site:fake-fetch-file#1, 7 )
return unit:assert-equals(1, 1) (: here I am going to check if db contains expected elements :) };
But let command is not valid for updating expression. Basex docs mention something about update:output and update:cache which may be of some use here but no exhaustive example is given for.
Anyone had similar problem?
BR
That perfectly suits my needs. I misnoticed the possibility for the "%unit:before" to be invoked before one single unit function. Thanks Christian for your fantastic product!
BR
On Tuesday, November 17, 2020, 7:41:42 PM GMT+1, Christian Grün christian.gruen@gmail.com wrote:
Dear BR dudzikp,
You can place your actual test your assertion in a second function with the %unit:after annotation. Another solution is to perform your update in a %unit:before function and test the result in the main function. See [1] for an example.
Cheers, CG
[1] https://docs.basex.org/wiki/Unit_Module#unit:before
On Tue, Nov 17, 2020 at 1:20 PM dudzikp@yahoo.com dudzikp@yahoo.com wrote:
Dear all,
I have not found a way to make basex unit module to test updating functions. I have a function site:add-movies which results in several db:add instructions. I try to achieve something like:
declare %unit:test %updating function test-site:download-movies() { let $result := site:add-movies( $test-site:site-db, test-site:fake-fetch-file#1, 7 )
return unit:assert-equals(1, 1) (: here I am going to check if db contains expected elements :) };
But let command is not valid for updating expression. Basex docs mention something about update:output and update:cache which may be of some use here but no exhaustive example is given for.
Anyone had similar problem?
BR
basex-talk@mailman.uni-konstanz.de