Created attachment 37216 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups. In discussion.
Created attachment 40071 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups. In discussion.
Created attachment 40072 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups. In discussion.
Created attachment 40078 [details] [review] Bug 13906 - Cucumber tests. See Cucumber/testsStructuring.tutorial for more info
Created attachment 41021 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups. Doing tests should be easy. One biggest hindrance in doing tests is the difficulty of doing so in Koha. We use a lot of hard-coded SQL, which occasionally requires quite a bit of fiddling to get it right. Satisfying complex object dependency chains is hard. For example, testing Overdue notice sending, one must create -letters -overuderules -circulationrules -borrowers -biblios -items -issues (checkouts) ... Also one must take care to clean up the database modifications afterward to make encapsulated tests which don't leak over other tests. This is especially so for front-end testing. TestObjectFactories significantly alleviate this pain, by offering preconfigured test object groups or enable creating test objects on demand. They try to recover from errors, like when the previous test crashed and left testing objects into the DB, preventing adding them again. Also they store what object they created to 3 different levels of stashes to facilitate complex test configurations, and they have the dignity to clean-up the test contexts after testing has happened (if the script doesn't crash)! USAGE: use t::db_dependent::TestObjects::Borrowers::BorrowerFactory; %#Setting up the test context my $testContext = {}; my $password = '1234'; my $borrowerFactory = t::db_dependent::TestObjects::Borrowers::BorrowerFactory->new(); my $borrowers = $borrowerFactory->createTestGroup([ {firstname => 'Olli-Antti', surname => 'Kivi', cardnumber => '1A01', branchcode => 'CPL', flags => '1', #superlibrarian, not exactly a very good way of doing permission testing? userid => 'mini_admin', password => $password, }, ], undef, $testContext); %#Test context set, starting testing: eval { ... #Run your tests here }; if ($@) { #Catch all leaking errors and gracefully terminate. warn $@; tearDown(); exit 1; } %#All tests done, tear down test context tearDown(); done_testing; sub tearDown { t::db_dependent::TestObjects::ObjectFactory->tearDownTestContext($testContext); }
Created attachment 41119 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups.
Hi Olli, If I try to see the tree of your bugs I see this the first bug to sent master to fix the others. This is your bugs tree for authentication rewrite: https://trello.com/b/o3uAES9s Why is in discussion ?
(In reply to Zeno Tajoli from comment #7) > Hi Olli, > > Why is in discussion ? Originally I made these factories to work best with Cucumber tests, and those have their own stashing and tearDown-mechanisms. Back then I didn't think far enough and those things have been dealt in the Cucumber framework. So all the other ObjectFactories, sans the BorrowerFactory are of the old model. I refactored Borrowerfactory to include the features from Cucumber-framework (multi-level stashing) but haven't done that for the rest of the ObjectFactories. So basically If one was to refactor this commit into something with only the BorrowerFactory and the parent ObjectFactory, this would be ok. I have tests and documentation to do for the REST API framework, so I can take a look at this after that, but the separation is a very easy task and a good exercise in getting to know the simplicity of these Factories. There are other bugs to test for the big authentication rewrite, if you feel like waiting for me to properly refactor this feature. I have built Bug 14540 to be stand-alone testable (with all dependencies), but most of these dependant bugs don't make much sense to test alone (since they do not have the necessary context to prove their usefulness. You can still safely apply this bug, since the non-refactored factories don't hinder testing the whole rewrite or interfere with Koha in any way.
Created attachment 41154 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation from HASHes or from preconfigured test groups.
Created attachment 41251 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation/deletion from HASHes.
Created attachment 41459 [details] [review] Bug 13906 - (follow-up) Add SystemPreferenceFactory (TestObjectFactory) This follow-up adds SystemPreferenceFactory into TestObject Factories.
Created attachment 41531 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation/deletion from HASHes.
Created attachment 42108 [details] [review] Bug 13906 - TestObjectFactoreis squashables
Created attachment 42141 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue This follow-up adds MessageQueue factory for generating messages into message_queue. The default hash key is field "from_address". MessageQueueFactory sets the newly generated messages into 'pending' status via C4::Letters to await further processing from your tests.
Created attachment 42161 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue
Created attachment 42169 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue
Created attachment 42430 [details] [review] Bug 13906 - TestObjectFactoreis squashables Fixed File::Fu::File version from PerlDependencies, 0.08 => 0.0.8
Created attachment 42552 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue C4::Letters has inconsistent hash key naming in some of the subroutines (EnqueueLetter vs. GetQueuedMessages). Modified the naming to match the database format so that hopefully it won't make our hair so grey with the factory at least.
Created attachment 42563 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue Fixes MessageQueue stash name to lower case.
Created attachment 42602 [details] [review] Bug 13906: (follow-up) - MessageQueueFactory for adding messages to message_queue
Created attachment 44293 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Holds test factory for v3.16
*ping* Is this moving forward?
Created attachment 47244 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Holds test factory for v3.16 Fixes a conflict.
Created attachment 47253 [details] [review] Bug 13906 (follow-up) - New TestObjectFactory for creating fines into accountlines Adds FinesFactory that creates new fines into accountlines.
(In reply to M. Tompsett from comment #22) > *ping* Is this moving forward? Don't know about the Koha-community, but we are constantly improving this feature and it works really well in practice (albeit a bit slowly). All our web-testing scripts are based on this feature and together with the Permission system rewrite We have code to rapidly deploy and receive a bunch of serials as well, but we haven't shared it yet. Also this code is for Koha 3.16. This all is aimed to enable doing web-testing in Koha in an effortless way. Bug 14536 - PageObject-pattern base implementation We are targeting to migrate to a "possibly" rolling update cycle with the Koha-community versions this summer. And these modern testing features hopefully will help us gain confidence in our codebase and enable following the community branches in semi-real time. Time will tell.
Created attachment 63244 [details] [review] Bug 13906 - TestObjectFactory(ies) for Koha objects. Enable easy Test object creation/deletion from HASHes. Doing tests should be easy. One biggest hindrance in doing tests is the difficulty of doing so in Koha. We use a lot of hard-coded SQL, which occasionally requires quite a bit of fiddling to get it right. Satisfying complex object dependency chains is hard. For example, testing Overdue notice sending, one must create -letters -overuderules -circulationrules -borrowers -biblios -items -issues (checkouts) ... Also one must take care to clean up the database modifications afterward to make encapsulated tests which don't leak over other tests. This is especially so for front-end testing. TestObjectFactories significantly alleviate this pain. They try to recover from errors, like when the previous test crashed and left testing objects into the DB, preventing adding them again. Also they store what object they created to 3 different levels of stashes to facilitate complex test configurations, and they have the dignity to clean-up the test contexts after testing has happened (if the script doesn't crash)! UNIT TESTS included! USAGE: use t::lib::TestObjects::PatronFactory; %#Setting up the test context my $testContext = {}; my $password = '1234'; my $patronFactory = t::lib::TestObjects::PatronFactory->new(); my $patrons = $patronFactory->createTestGroup([ {firstname => 'Olli-Antti', surname => 'Kivi', cardnumber => '1A01', branchcode => 'CPL', flags => '1', #superlibrarian, not exactly a very good way of doing permission testing? userid => 'mini_admin', password => $password, }, ], undef, $testContext); %#Test context set, starting testing: eval { ... #Run your tests here }; if ($@) { #Catch all leaking errors and gracefully terminate. warn $@; tearDown(); exit 1; } %#All tests done, tear down test context tearDown(); done_testing; sub tearDown { t::lib::TestObjects::ObjectFactory->tearDownTestContext($testContext); }
Could builder->build_object cover this case?
(In reply to Josef Moravec from comment #27) > Could builder->build_object cover this case? I think you're right.. this can probably be closed as a duplicate at this point?
(In reply to Martin Renvoize from comment #28) > (In reply to Josef Moravec from comment #27) > > Could builder->build_object cover this case? > > I think you're right.. this can probably be closed as a duplicate at this > point? I'll close it.