Re: [basex-talk] Automatically generating test cases. Hidden feature?
The compliment is well-deserved ;-) Yes, after my mind settled down on what I wrote, I realized this too. The annotation nor the anonymous function itself (a partial could have served the same function) wasn't necessary. So it's just plain cool instead of very cool. It was mostly my sudden enthousiasm for the possibilities this approach opens for an alternative testing approach. I always thought about the unit module as having to write an explicit test suite with the unit annotations and never realized that the unit:assert functions can very well be used on their own. In my case in the context of generative/property-based testing. Cheers, --Marc On Wed, Jan 13, 2016 at 8:43 AM, Christian Grünwrote: > Hi Marc, > >> BaseX, the gift that keeps on giving, thanks to all that make it possible. > > One of the nicest compliments that we got so far… Thanks ;) > >> So, a bit to my amazement, the following works: >> >> let $equals := >> %unit:test >> function($a,$b) { >> unit:assert-equals($a,$b, 'Not equal') >> } >> return >> $equals(4,3) > > Yes, it does, it will do so in the future. To add some more surprises: > You can omit the %unit:test annotation, because it’s the > unit:assert-equals function that raises the error in the XQUnit > namespace. > > Cheers, > Christian -- --Marc
Re: [basex-talk] Automatically generating test cases. Hidden feature?
+1 on both topics: product/team and the unit-module. I, too, discovered the power of unit-testing and the unit-module lately. Using the unit-module I build unit-tests to test the basic rules, the axioms, of my modules and it works great. It is a big help in keeping the whole thing stable. One minor thing: it is not very fast, so I've to think well with what and how much I want to test, especially in case of generated test-cases. Which actually is a good thing in this case. Rob -Oorspronkelijk bericht- Van: basex-talk-boun...@mailman.uni-konstanz.de [mailto:basex-talk-boun...@mailman.uni-konstanz.de] Namens Marc van Grootel Verzonden: woensdag 13 januari 2016 10:08 Aan: Christian Grün CC: BaseX Onderwerp: Re: [basex-talk] Automatically generating test cases. Hidden feature? The compliment is well-deserved ;-) Yes, after my mind settled down on what I wrote, I realized this too. The annotation nor the anonymous function itself (a partial could have served the same function) wasn't necessary. So it's just plain cool instead of very cool. It was mostly my sudden enthousiasm for the possibilities this approach opens for an alternative testing approach. I always thought about the unit module as having to write an explicit test suite with the unit annotations and never realized that the unit:assert functions can very well be used on their own. In my case in the context of generative/property-based testing. Cheers, --Marc On Wed, Jan 13, 2016 at 8:43 AM, Christian Grün <christian.gr...@gmail.com> wrote: > Hi Marc, > >> BaseX, the gift that keeps on giving, thanks to all that make it possible. > > One of the nicest compliments that we got so far… Thanks ;) > >> So, a bit to my amazement, the following works: >> >> let $equals := >> %unit:test >> function($a,$b) { >> unit:assert-equals($a,$b, 'Not equal') >> } >> return >> $equals(4,3) > > Yes, it does, it will do so in the future. To add some more surprises: > You can omit the %unit:test annotation, because it’s the > unit:assert-equals function that raises the error in the XQUnit > namespace. > > Cheers, > Christian -- --Marc
Re: [basex-talk] Automatically generating test cases. Hidden feature?
Hi Marc, > BaseX, the gift that keeps on giving, thanks to all that make it possible. One of the nicest compliments that we got so far… Thanks ;) > So, a bit to my amazement, the following works: > > let $equals := > %unit:test > function($a,$b) { > unit:assert-equals($a,$b, 'Not equal') > } > return > $equals(4,3) Yes, it does, it will do so in the future. To add some more surprises: You can omit the %unit:test annotation, because it’s the unit:assert-equals function that raises the error in the XQUnit namespace. Cheers, Christian
[basex-talk] Automatically generating test cases. Hidden feature?
Hi, Been a long time since posting. Work is very busy recently. Luckily for me a lot of it involves XQuery ;-) I am elaborating some examples [1] that show off the use of my Origami [2] library. The most promising ones I will turn in to blog posts or a wiki at some point. Recently I've been reading a bit about generative testing (or property-based testing) and libraries like Haskell's QuickCheck. I hope to be able to show that we can use such techniques in combination with RelaxNG and the concepts that Eric van der Vlist describes in Examplotron [3] to mutate XML instances guided by a schema that I can then turn into automatically generated tests. It's still early days and time is limited but I did stumble onto something interesting that I wanted to share here. If you already use similar techniques I would be very interested to hear about it. I was contemplating if it was possible to create anonymous unit test functions that I can invoke with generated test input. So, a bit to my amazement, the following works: let $equals := %unit:test function($a,$b) { unit:assert-equals($a,$b, 'Not equal') } return $equals(4,3) This function raises the unit:UNIT0001 exception with the message "Item 1: 3 expected, 4 returned". Cool! So if this is possible can we also catch a failure and turn it into data? let $equals := %unit:test function($a,$b) { unit:assert-equals($a,$b, 'Not equal') } return try { $equals(4,3) } catch * { { $err:code } { $err:description } { $err:value } { $err:module } { $err:line-number } { $err:column-number } } This too works and produces an XML fragment recording the failure. Very cool! unit:UNIT0001 Item 1: 3 expected, 4 returned. Not equal .../origami-examples/check/demo.xq 23 24 I am not sure if this a hidden or an intentional feature of the BaseX unit module. I sure hope that it doesn't go away in future releases as I intend to leverage this in an alternative testing module. BaseX, the gift that keeps on giving, thanks to all that make it possible. --Marc [1] https://github.com/xokomola/origami-examples [2] https://github.com/xokomola/origami [3] http://examplotron.org/