[Gambas-devel] Suggestion : Gambas Unit Testing

Julio Sanchez jusabejusabe at ...176...
Tue Dec 9 12:35:14 CET 2014


Adrien Prokopowicz:

Very interesting!!

Regards

Julio

2014-12-09 1:57 GMT+01:00 Adrien Prokopowicz <adrien.prokopowicz at ...176...>:

> Hello everyone !
>
> With the amount of features to test in my various Gambas projects, I
> started feeling that it was a pain to write the tests, run *all* of them,
> and analyzing their output each time I had to make a change, thus leading
> to forget to run simple tests (see the last gb.xml issue...).
>
> Therefore, in order to automate and simplify this whole process, I decided
> to start working on an Unit Testing component for Gambas.
>
> It works quite simply : in your project, just create a class that inherits
> the UnitTest class, move it inside an "unit" folder in your project source
> directory, and implement your test in the _Run() method, using the
> different Assert() and Fail() methods, documented in the component's
> 'AssertionsTests' test.
>
> To run all the tests at once, just use the _UnitTestLauncher module as the
> starting class instead of your project's default one (this can be achieved
> easily using 'gbx3 -s _UnitTestLauncher' inside your project's directory.
> Each test is run inside a separate Task, therefore preventing a bad test
> to crash the whole test suite, and allowing you to easily multi-task it,
> using 'gbx3 -s _UnitTestLauncher -- -j <number of parallel tasks>'.
>
> Inside the attached component, I also made 3 tests, that show how the
> component handles the different scenarios :
>
> - The 'MyGoodUnitTest' will run fine, but will sleep 0.5s before ending
> (to show that the component will use another thread to run the other tests,
> if there is any available, which is not the case by default).
> - The 'MyBadUnitTest' will fail because of an (obvious) false assert. It
> will then show the stack trace of where the error raised, as well as a
> reason text (or just 'Assertion failed.' by default).
> - The 'MyVeryBadUnitTest' will fail because of an error raised by the
> interpreter, here 'Division by zero'. Note that the result will be similar
> if the test completely crashes (Segfault...), you just won't have a stack
> trace available.
>
> Of course this is just a proof of concept, there are a few things i would
> like to add to properly finish this component, such as a proper IDE
> integration, a standardized xUnit XML output, tweaking the archiver so the
> tests won't be in the final executable, maybe its own command (like gbt3)
> ...
>
> What do you think ?
>
> --
> Adrien Prokopowicz
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-devel mailing list
> Gambas-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20141209/2d06a432/attachment.html>


More information about the Devel mailing list