[Gambas-devel] Suggestion : Gambas Unit Testing

Adrien Prokopowicz adrien.prokopowicz at ...176...
Wed Dec 10 23:20:29 CET 2014


Le Wed, 10 Dec 2014 10:52:22 +0100, Benoît Minisini  
<gambas at ...1...> a écrit:

> Le 10/12/2014 10:35, Adrien Prokopowicz a écrit :
>
>> Because calling this method would run the test, but not update the
>> UnitTest's internal state variables, nor catch the (potential) errors
>> correctly. You should use the public Start() method for that.
>
> It's not a valid argument for me. If the user has to write the method,
> it must have a normal public name.

I agree. That's why I was suggesting the protected accessibility.

> Moreover, running the UnitTest will start the static public Main()
> method, so the Start() method should be named Main(), or called by  
> Main().

I don't understand, what 'static public Main()' are you talking about ?
There is no such method in UnitTest : the test is never ran directly,
it's the _UnitTestLauncher that creates a task for each UnitTest, which
then runs the test.

Actually, the Start() method should not even be exported, as the user
never starts a test from application code (only the launcher does that).

I will have to change the UnitTest class quite a bit, so that internal
methods stay away from user-accessible methods (like Start).

>> I thought about using a text file only for importing/exporting test
>> results,
>> because I would like the IDE's report to be updated in (almost)  
>> real-time.
>> For example, if only 30 of the 100 tests are done, it would be nice to  
>> show
>> them already, rather than just having a waiting cursor.
>
> Nice, but what for? If you run a test, you won't modify the project at
> the same time...

Just for user comfort. Personally, I find it very frustrating when an
application just tells you "please wait" when you could already see part
of the results. But maybe it's just me.

> But the unittest must be runnable from the command line, so its output
> should be text printed on the standard output. So we can imagine that
> they are run in the background by the IDE, and that the output will be
> catched and transformed in a nice result table. And then you gain your
> "real-time" feature.

Unit tests are already runnable from command line (the command is just
ugly at the moment), the following works on any project for which
the gb.unit component is enabled :

   [adrien at ...707... gb.unit]$ gbx3 ./ -s "_UnitTestLauncher"
   ----- Test AssertionsTests (#0) succeeded -----
   ----- Test MyBadUnitTest (#1) failed -----
	  Reason: Assertion failed.
	  Stack trace :
		  MyBadUnitTest._Run.8
   ----- Test MyGoodUnitTest (#2) succeeded -----
   ----- Test MyVeryBadUnitTest (#3) failed -----
	  MyVeryBadUnitTest failed due to an unexpected error.
	  Reason: Division by zero
	  Stack trace :
		  MyVeryBadUnitTest._Run.8
   4 tests finished. 2 sucessful tests, 2 failed tests.
   [adrien at ...707... gb.unit]$

I plan to add another flag to this command that would transform the
output into something more convenient to parse for the IDE.

Regards,

-- 
Adrien Prokopowicz




More information about the Devel mailing list