[Gambas-user] Integrate unittest component to Gambas
Christof Thalhofer
chrisml at deganius.de
Sat Apr 21 22:04:22 CEST 2018
Am 21.04.2018 um 19:43 schrieb Benoît Minisini:
> No problem to add a new component, but I'm not sure to understand your
> interface. So maybe I will tell rubbish.
Maybe I will tell rubbish too. I forked this project from
http://comunit.sourceforge.net/
So I did not develop the interface but I rearranged it to work in
Gambas. I fixed a couple of selfmade bugs and ran it for a while in my
projects. Like so:
Just try it out with <F5>
In TesteStartRunner the unittest tests itself in two ways:
r.Test(...)
delivers the testresult(s) to the console.
(This is the way I work very often. I first write a test, and then do my
coding. If I hit <F5> the Unittest runs and shows the results in the
console. If everything is ok, my new method is ok ...)
Be aware that the tests which test gb.deg.unittest itself intentionally
are not successful.
r.ShowTestForm()
delivers the GUI
(which is nice but I use it not very often, it is nice for playing
around, but quite annoying when constantly coding on new things)
> ATestContainer -> it's actually the parent class for all tests?
Yes ... and no ... it is the parent class for all test *containers*. A
container can contain a lot of tests. All test containers in a project
(this is the "Test Suite") are identified by being inherited from
ATestContainer.
I know, "ATestContainer" is not a nice name ...
> UnitTest -> Why this class? And why do you have to instanciate it? If it
> is just there to run all the test, I suggest mergin UnitTest and
> ATestContainer, and just make a static method "Run()" to run all the
> unit tests in the exported classes inheriting the new "UnitTest".
UnitTest identifies all testcontainers within a project, collects them
and runs all tests in all containers, or all tests in a single
container, or even just single test and then collects and displays the
results.
Merging ATestContainer and UnitTest could be much more elegant, yes.
I will try it out.
For now I was not able to make UnitTest.Test (the equivalent of "run")
static.
> As for the GUI, I think it should be be extern to the tested project and
> merged into the IDE.
Yes. But I think it is important to be able to run the unittest inside
the project itself, even afterwards, when it is compiled, and not only
through the IDE. There I think of automatic testing of all kind of
libraries, components or programs.
> The result of the tests should be provided to the standard output in a
> standard format that will be displayed by your GUI in the IDE.
Do you know a standard format for unittesting results? Something like
this? https://testanything.org/
This is for displaying only.
You mean sth like JSON? Ok, there would have to be coded methods like:
TestResult.ToJson
and
TestResult.FromJson
to ex- and import Testresults.
> The unit test will be run by forcing the startup class run by the
> interpreter to "UnitTest".
Ah ok, now I understand ... this would be indeed very, very cool.
gbr3 --test myproject.gambas
> What do you think about that? Does it raise any problem?
No Idea ... a lot ... my time (sigh) ... I have to try.
Especially the "standard format" would cause a hefty rewrite.
Now I drink a beer ... Santé !
:-)
Alles Gute
Christof Thalhofer
--
Dies ist keine Signatur
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180421/29098674/attachment.sig>
More information about the User
mailing list