perlquestion
Discipulus
Hello folks!<P>
I'm writing a lot of test nowadays (finally!) and currently I have a lot of duplicated code in them. This is because I'm testing a simple backup solution and many tests of mines requires backup scenarios to be present in a temporary folder.<P>
So I create and delete files and folders in my tests, I read a write files permissions etc.. and to accomplish these tasks I use CPAN modules not needed by my module but only during tests.<P>
1) I can have a dedicated module with all required modules imported an exposing all subs I need. Where? How? Where the dependencies of this (somehow private module) have to be specified? In the <C>BUILD_REQUIRES</C> in the <C>Makefile.PL</C> of the main module?<P>
2) have a special part of the main module (or a dedicated package?) loaded only during tests? How to trigger this behaviour?<P>
3) (probably worst approach) build only one test file, a big one with all modules used and all subs defined in the very same file<P>
I did not found anything related to the matter (maybe because of generic terms of the search..) nor advice in my [id://1202418|bibliotheca] and asking in the chatter box I had a precious suggestion by [Corion] that i'll present below (for future readers) but I also want to know from you other possible approaches or tecniques, and if i missed some detail:<P>
[Corion] suggested option 1: and pointed me to his [https://github.com/Corion/WWW-Mechanize-Chrome/blob/master/t/helper.pm|WWW-Mechanize-Chrome]'s <C>helper.pm</C> testing module. The solution is simple and worth to share (I see <C># hide from CPAN indexer</C> can some elaborate this?).<P>
Have you other approach? Some quirk I missed? Something to pay attention to?<P>
thanks<P>
<c>
</c><P>
L*<P>
<div class="pmsig"><div class="pmsig-174111">
There are no rules, there are no thumbs..<BR>
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
</div></div><!-- Wiki2Monks {"version":1.142} -->