[Gambas-devel] Suggestion : Gambas Unit Testing

Benoît Minisini gambas at ...1...
Wed Dec 10 10:52:22 CET 2014


Le 10/12/2014 10:35, Adrien Prokopowicz a écrit :
>
> I see a 'basic test case' like this :
>
> 	'If we use standard output comparison
> 	myObject = giveMeMyObject()
> 	Print myObject.value1
> 	Print myObject.value2	
> 	-- MyOtherFile.txt -- 8< --
> 	"expected value 1"
> 	"expected value 2"
>
>        -- vs. --
>
> 	'If we use the assets() methods
> 	myObject = giveMeMyObject()
> 	Me.Assert(myObject.value1 = "expected value 1")
> 	Me.Assert(myObject.value2 = "expected value 2")
>
> I don't know about you, but to me the second option looks way clearer and
> easier to maintain. :-)
>
>>> For IDE integration, what I had in mind was, as you said, creating a
>>> new "form" type, so you could simply do New>Unit Test..., give it a name
>>> and immediately start implementing the pre-generated _Run() method.
>>
>> Why an hidden method?
>>
>
> 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.

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

>
> Another (cleaner) possibility would be switching this method's
> accessibility to protected (bumping Tobias' thread here [0]). ;)
>
>>> Then, starting a test (either automatically after compilation or
>>> manually
>>>    from a menu entry) would open a tab containing the full report.
>>> I can work on that if you want.
>>>
>>> In the meantime, I will start working on a class to manage and retrieve
>>> the results from the testing process, so it can directly be used by the
>>> IDE (and maybe other projects).
>>>
>>
>> OK, so the tests results should be a text file format easily transformed
>> into a nice table by the IDE. Please don't use XML. :-)
>
> 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...

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.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list