Allow for Microsoft-Format unittests to be run by the unit testing framework #14


closed feature
metamoof submitted on Fri 31 August 2018 #

Hi,

Microsoft have also release a unit testing framework for powerquery, though it requires the framework to be in the same file, by the looks of things.

It would be good if the unittest module could also cope with unit tests expressed as Facts, to make it easy for people who started in that framework to port it to the LibPQ way of doing things

sio commented on Fri 31 August 2018 # OWNER

Thank you for pointing that out! It's great that they have finally offered an unit testing solution. It is unfortunate though that it is not included into the standard library. Copy-pasting functions into each project makes updating and maintaining them very difficult. I suspect the framework will be significantly reworked when (and if) it'll get widely adopted, and only then (maybe) it will become part of the language.

Even though I see no benefits to their approach, adding support for it was an interesting challenge :) I've added my own implementation of Facts and Facts.Summarize functions to the ms-tests branch. They are fully compatible input-wise with Microsoft's implementation but produce output that can be integrated into existing LibPQ UnitTest framework. More than that, UnitTest.Discover now supports test discovery for fact based tests if they are marked with proper metadata (LibPQ.TestSuite="Facts")!

The code will remain in the feature branch for a while, but please test it and report any problems. Sometime later I'll write the required documentation and will merge ms-tests into master.

PS: Execute LibPQ("UnitTest.Discover")(false) and Facts.Summarize(LibPQ("Tests.MicrosoftUnitTestDemo.pq")) to see new tests in action. Sample test code is included into Modules/Tests.MicrosoftUnitTestDemo.pq

sio labeled feature on Fri 31 August 2018
sio closed this issue in commit 0c969ea on Sun 02 September 2018
sio commented on Sun 02 September 2018 # OWNER

Support for fact based tests has been merged into master. See this article for documentation.

Thank you again!