[Wtr-general] Need advice for splitting large scripts into smaller ones

Paul Carvalho tester.paul at gmail.com
Thu Mar 2 15:59:44 EST 2006


I have this one script that I'm working on that is just getting bigger as I
go along.  I would like to break out some of the smaller chunks/tests into
separate script files, but I'm not sure of the logistics of this.  I tried
looking at the unittests but I couldn't answer my questions by looking at
them.

For example, my one (master) script is set up like the following:
----
#includes
#global variables

class TC_blahblahblah < Test::Unit::TestCase
    def cust_method_1
        ...
    end

    def cust_method_2
        ...
    end

    test_a_somename
        yadda yadda yadda
    end

    test_b_somename
    ....
end
----

Now, if I break out "test_a_somename" into a separate script, what is the
correct format for calling/running it from within the master script?

In the new sub-script, do I have to repeat the "class TC_blahblahblah <
Test::Unit::TestCase" structure, or just put the "test_a_somename"
structure?  Do I have to re-include all the require/include lines that were
in the master script?  (I don't think I should, but I'm not sure.)

If I have methods that are defined in the master script, will they be
properly called from one of the sub-scripts, or do I have to put them in the
sub-scripts too? (I expect it to work if they're only defined in the master
script.)

Please forgive these basic questions.  I searched the message archives but I
couldn't find anything helpful other than "you should break up large scripts
into smaller ones when they get too long (like ~ 1000 lines)".  And I
haven't had any success scanning the other Ruby/Watir documentation to give
me practical advice on how to do this either.

Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060302/25152147/attachment.html 


More information about the Wtr-general mailing list