Re: Idea: run tests in transactions, roll them back
Moritz Lenz <[email protected]> Mon, 15 Jun 2015 16:53:55 +0200
| Newsgroups | gmane.comp.otrs.devel |
|---|---|
| Message-ID | <[email protected]> |
On 06/15/2015 09:18 AM, Martin Gruner wrote:
> Hello Moritz,
>
> this is a nice idea indeed. Technically this could be easily implemented
> in the UnitTestHelper as a new parameter (like
> RestoreSystemConfiguration) which also cleans up the cache after the test.
>
> It has some limitations (MyISAM, Selenium etc.), but could help with
> some things as well. Transactions are a topic that we should adress also
> in the regular code of OTRS at some point, but this might be a bigger
> effort. For now we could just use $DBObject->{dbh}->*() in the Helper
> object.
>
> If you want you can create a test implementation as a PR that actually
> tests the functionality of the rollback. Then I could merge it into
> master and check what our unit test servers say about it. :-P
And here it is: https://github.com/OTRS/otrs/pull/607
If the smoke tests come out green (or green enough for your taste ;-),
I'd propose an API like
my $ScopeGuard = $Self->CleanupOnDestroy();
( or maybe $HelperObject->CleanupOnDestroy )
and when $ScopeGuard goes out of scope (due to the test file being
done), its DESTROY method will roll back the current transaction and
clean the cache.
Depending on the scoping of these objects, this behavior might go into
the UnitTest or UnitTest::Helper objects -- but currently I don't have a
good overview whether they live just for one test file, or longer.
Cheers,
Moritz
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev
smime.p7s
(application/x-pkcs7-signature, 6.2 KB) - not displayed