Unit tests and mock module
Hi Koha-devel, I just pushed t/Members_AttributeTypes.t unit tests that fake the database. The test here could be redundant with t/db_dependent tests I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) * decide we should prefer db_dependent tests and limit the use of Mock to specific cases I feel that deciding nothing will result in a poor readability of what tests what, and some difficulties to know which test is to update when you update a sub. So, as Mock is introduced, we must speak of it. Your opinion ? -- Paul POULAIN http://www.biblibre.com Expert en Logiciels Libres pour l'info-doc Tel : (33) 4 91 81 35 08
On Fri, Sep 7, 2012 at 9:41 AM, Paul Poulain <paul.poulain@biblibre.com> wrote:
Hi Koha-devel,
I just pushed t/Members_AttributeTypes.t unit tests that fake the database. The test here could be redundant with t/db_dependent tests
I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) * decide we should prefer db_dependent tests and limit the use of Mock to specific cases
+1 for Mock. Regards To+
Paul, I just pushed t/Members_AttributeTypes.t unit tests that fake the
database. The test here could be redundant with t/db_dependent tests
I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database)
This option is -- in my opinion -- much superior. However, a db_dependent test is better than nothing.
* decide we should prefer db_dependent tests and limit the use of Mock to specific cases
I feel that deciding nothing will result in a poor readability of what tests what, and some difficulties to know which test is to update when you update a sub. So, as Mock is introduced, we must speak of it.
I would rather duplicate tests than have untested code. I see no reason for making an absolute decision. Regards, Jared -- Jared Camins-Esakov Bibliographer, C & P Bibliography Services, LLC (phone) +1 (917) 727-3445 (e-mail) jcamins@cpbibliography.com (web) http://www.cpbibliography.com/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Op 07-09-12 14:41, Paul Poulain schreef:
* decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) * decide we should prefer db_dependent tests and limit the use of Mock to specific cases
The problem with many things in db_dependent is not that it requires a database to run the tests, it's that the modules under test, or required by the modules under test, load database information in their BEGIN block. These should be fixed where we can, as it's a) unnecessary db activity if we never use that result, and b) I suspect will have issues with persistence. As for mocking a database, I think it's generally a good idea, unless what you're actually testing is that something is talking to the database itself correctly (there may even be ways around that too.) - -- Robin Sheat Catalyst IT Ltd. ? +64 4 803 2204 GPG: 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBJ7bUACgkQFNNkhamc623ZwgCeM8e3faOxxozD5ufttfYtHMqh zIIAmgK38utk56aiZoQBIgOzBogFDggH =+Pq5 -----END PGP SIGNATURE-----
On Fri, Sep 07, 2012 at 02:41:18PM +0200, Paul Poulain wrote:
Hi Koha-devel,
I just pushed t/Members_AttributeTypes.t unit tests that fake the database. The test here could be redundant with t/db_dependent tests
I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) Mocking the tests allows for more focused testing. The problem with the db_dependent tests is that so many variables get added to the mix. I think that we should recommend using Mock but due to the horrible jungle of dependencies in much of our code some things force us to use a db_dependent test C.
-- Colin Campbell Chief Software Engineer, PTFS Europe Limited Content Management and Library Solutions +44 (0) 800 756 6803 (phone) +44 (0) 7759 633626 (mobile) colin.campbell@ptfs-europe.com skype: colin_campbell2 http://www.ptfs-europe.com
I have been writing some new unit tests and have had some success using Mock. I have found that it allows me to have more control over some of the more unwieldy modules. So +1 for Mock On Sep 7, 2012, at 8:36 AM, Colin Campbell <colin.campbell@ptfs-europe.com> wrote:
On Fri, Sep 07, 2012 at 02:41:18PM +0200, Paul Poulain wrote:
Hi Koha-devel,
I just pushed t/Members_AttributeTypes.t unit tests that fake the database. The test here could be redundant with t/db_dependent tests
I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) Mocking the tests allows for more focused testing. The problem with the db_dependent tests is that so many variables get added to the mix. I think that we should recommend using Mock but due to the horrible jungle of dependencies in much of our code some things force us to use a db_dependent test C.
-- Colin Campbell Chief Software Engineer, PTFS Europe Limited Content Management and Library Solutions +44 (0) 800 756 6803 (phone) +44 (0) 7759 633626 (mobile) colin.campbell@ptfs-europe.com skype: colin_campbell2
http://www.ptfs-europe.com _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
I have been writing some new unit tests and have had some success using Mock. I have found that it allows me to have more control over some of the more unwieldy modules. So +1 for Mock On Sep 7, 2012, at 8:36 AM, Colin Campbell <colin.campbell@ptfs-europe.com> wrote:
On Fri, Sep 07, 2012 at 02:41:18PM +0200, Paul Poulain wrote:
Hi Koha-devel,
I just pushed t/Members_AttributeTypes.t unit tests that fake the database. The test here could be redundant with t/db_dependent tests
I feel we should be aware of that, and : * decide Mock is the way to go, and promote using of Mock, removing db_dependent tests (that fail if you don't have a database) Mocking the tests allows for more focused testing. The problem with the db_dependent tests is that so many variables get added to the mix. I think that we should recommend using Mock but due to the horrible jungle of dependencies in much of our code some things force us to use a db_dependent test C.
-- Colin Campbell Chief Software Engineer, PTFS Europe Limited Content Management and Library Solutions +44 (0) 800 756 6803 (phone) +44 (0) 7759 633626 (mobile) colin.campbell@ptfs-europe.com skype: colin_campbell2
http://www.ptfs-europe.com _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
participants (7)
-
Colin Campbell -
Jared Camins-Esakov -
Paul Poulain -
Robin Sheat -
Tomas Cohen Arazi -
Travis Elliott Davis -
Travis Elliott Davis