[Gambas-user] New component gb.test

Christof Thalhofer chrisml at deganius.de
Sun May 20 15:38:32 CEST 2018


Am 20.05.2018 um 13:40 schrieb Tobias Boege:

> The ["gbx3", "-s", Test, Project] is a stopgap until it's clear how much
> convenience we want to code into the interpreter for running tests.
> Currently a test must be a startup-able class with a Static Public Main,
> and I couldn't say it doesn't make sense to me this way.

Ok.

I think I have to show you, why I wrote gb.deg.unittest and how I work
with it, to explain, why eventually your approach does not really fit my
needs.

I have written a database library which extends db connections (lowest
level) then does a lot of stuff with sql (lower level), then an ORM
(high level). High level depends on lower and so on.

This stuff is tested by a couple of modules (Testcontainer) which
contain testmethods each containing one or more asserts.

If I am working remote one single run of all tests lasts a couple of
minutes. It is good to be sure that everything works before it goes to
production. This is classic unittesting like done in CI.

For that I would execute Unittest.Test() that does:

Testcontainer1
It creates a database on the db-server. (fixture)
Creates tables in the database (fixture)
Runs connections and some functionality of connections. (tests)
Deletes tables in the database (cleanup)
Destroys the database on the db-server. (cleanup)

Testcontainer2
It creates a database on the db-server. (fixture)
Creates tables in the database (fixture)
Runs Sql_functionality1 (tests)
Deletes tables in the database (cleanup)
Creates tables in the database (fixture)
Runs Sql_functionality2 (tests)
Deletes tables in the database (cleanup)
...
Destroys the database on the db-server. (cleanup)

Testcontainer3
It creates a database on the db-server. (fixture)
Creates tables for ORM in the database (fixture)
Runs ORM_functionality1 (test)
Runs ORM_functionality2 (test)
Runs ORM_functionality3 (test)
...
Deletes tables for ORM in the database (cleanup)
Destroys the database on the db-server. (cleanup)

But:

When I work on this stuff I do test driven development and I do not want
to run all but only one single test while coding.

I code a little and to test I hit F5 which executes for example:

Unittest.Test("TestContainer3", "ORM_functionality2")

This is done in 10 seconds.

Running all tests in TestContainer3 would last 45 secondy which would be
annoying.

----------------------------------------------------------

I wrote gb.deg.unittest primarily for easily and fast executing testcode
while developing with the advantage to store and repeat it later. For
that I needed the separation of single tests in a testcontainer that
ensures the exact environment.

I think you have classical unittesting in mind which is done
automatically during CI. There always everything is tested.


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/20180520/c2e73065/attachment.sig>


More information about the User mailing list