David,

That error message indicates that $ie is nil, which is to say, it
hasn't been initialized. It needs to be assigned in the test_* method
or the initialize method. (Or you need to get fancy, which is what we
do in our unit tests.)

You said that you are trying to structure your test scripts. I suggest
you do this in smaller steps. First just put the common code in a
separate method (not called test*) in the same class. Then move it
outside the class. And only then move it to a new file. There are
small gotcha's with each step, so it's worth taking these small steps
until you understand the source of each of them.

Bret

On 3/20/06, David Solis <[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
> I'm running into a problem I think is a probably a programming error in my 
> part.
>
> Here  is what I'm trying to accomplish: I have script with 2800 lines of  
> code. My test cases in the script have many repeatable steps. For each  test 
> case, I'm basically coding the same steps over an over again and  thus I get 
> hundreds of lines of code.
>
> My  first inclination was to break out the test and make them into separate  
> files so that the script is not so big and less error prone. But I  would be 
> doing the same thing as I was doing earlier except now I would  have to 
> maintain many files rather one.
>
> So  what I want to do is create a method that contains the repeatable steps  
> that are used in every test case and call the method when I need to  execute 
> the steps. The method would live in separate file. Sounds easy,  right?  
> Well, when I try to a get this error:        !
>
> 1) Error:
> test_steps(AccountManagementSteps):
> NoMethodError: undefined method `link' for nil:NilClass
>     ./negative_tierI_steps.rb:37:in `test_steps'
>     2) Error:
> test_01_account_management(TC_Negative):
> ArgumentError: wrong number of arguments (0 for 1)
>     
> C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in
>  `initialize'
>     
> C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in
>  `new'
>       
> C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in
>   `test_01_account_management'
>
> Here  is the code. The method I'm calling is called AccountManagementSteps.  
> Require 'setup' halls my require statements including so I know the  script 
> has the proper require statements. require  'negative_tierI_steps.rb' 
> contains the steps that are given me the  problem.
>
> require 'setup'
> require  'negative_tierI_steps.rb'
>
> TOPDIR = File.join(File.dirname(__FILE__), '..')
> $LOAD_PATH.unshift TOPDIR
>
>
> class TC_Negative <  Test::Unit::TestCase
>
>     def test_01_account_management
>     puts ''; puts '';
>     puts "############ Starting Test Class: TC_tierI_negative_tests   
> ############";
>     puts ''
>     puts 'Executing test 01 - Account Management Access'
>     puts ''
>               @login = Login.new($user, $password, $url, $submit_key);
>                # create a random Admin user name
>                @random_name = UserRandomName.new();
>                $username = @random_name.User();
>                # Create a new Admin    User
>                @admin_user = CreateUser.new($username);
>                # Verify that user was created
>                assert($ie.contains_text($save_msg));
>     @login.logout("admin");
>              assert($ie.contains_text($logoff_msg));
>             @login.shutdown();
> # Login as  superuser
>                          @login = Login.new($user, $password, $url, 
> $submit_key);
>                          @group_details = 0
>     set_group = SetPermission.new()
>       set_group.fSteps(@group_details);
>                            assert($ie.contains_text($save_msg));
>                          @login.logout("admin");
>                            assert($ie.contains_text($logoff_msg));
>                          @login.shutdown();
>
>                          ! @login =    Login.new($username, $password, $url, 
> $submit_key);
>     @steps = AccountManagementSteps.new()
>     @steps.test_steps()
>    end
>
> This is the code in the method I'm calling.
>
> require 'setup'
> require 'watir'
> require 'test/unit'
> require 'test/unit/ui/console/testrunner'
> require 'watir/testUnitAddons'
>
> class AccountManagementSteps < Test::Unit::TestCase
>
>   def initialize()
>   end
>
>     def   test_steps()
>     $ie.link(:text, "Account management").click();
>                            assert($ie.contains_text("Manage Accounts"));
>     $ie.link(:text, "Manage settings").click();
>                            assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Manage affiliates").click();
>                            assert($ie.contains_text($no_autho_msg));
>       $ie.link(:text, "Admin authentication").click();
>     $ie.link(:text, "AAUT").click();
>       assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Payment processing").click();
>                            assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Promotions").click();
>     $ie.link(:text, "Create New Promotion").click();
>                           !     assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Content keys").click();
>                            assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Pay Model").click();
>     table = $ie.table(:index, 9)
>     #table.flash
>     sleep 1
>     table[1][5].image(:name, "updatetop").click
>       assert($ie.contains_text($no_permission_msg))
> !     $ie.link(:text, "Game Library").click();
>     table = $ie.table(:index, 9)
>     sleep 1
>     table[1][3].image(:name,   "updatetop").click
>       assert($ie.contains_text($no_permission_msg))
>     $ie.link(:text, "Game Settings").click();
>       assert($ie.contains_text($no_autho_msg));
>     $ie.link(:text, "Game Menu Tabs").click();
>     table = $ie.table(:index, 9)
>     sleep   1
>     table[1][3].image(:name, "updatetop").click
>       assert($ie.contains_text($no_permission_msg))
>       $ie.link(:text, "Community Games").click();
>     #table = $ie.table(:index, 9)
>     #sleep 1
>     #table[1][3].image(:name, "updatetop").click
>       #assert($ie.contains_text($no_permission_msg))
>     $ie.link(:text, "Community User Migration").click();
>     # No update button available. Need to figure out how to assert false for 
> no   buttons
>     $ie.link(:text, "Community User Upload").click();
>     # Need address attaching files
>     #$ie.link(:text, "Community Management").click();
>     #$ie.text_field(:name,  "newCommunity").set("Test")
>     #table = $ie.table(:index, 10)
>     #sleep 1
>     #table[1][3].image(:name,   "form_top_singl_create").click
>       #assert($ie.contains_text($no_permission_msg))
>     $ie.link(:text, "Jackpot List").click();
>     # Jackpot lists allowed - research test case
>     $ie.link(:text, "Jackpot Details").click();
>     table = $ie.table(:index, 9)
>     sleep 1    !
>     table[1][3].image(:name,   "updatetop").click
>       assert($ie.contains_text($no_permission_msg))
>       $ie.link(:text, "Jackpot Adjustments").click();
>     $ie.text_field(:name, "AdjustAmt").set("1000")
>     $ie.text_field(:name, "ReasonText").set("This is a test")
>     table = $ie.table(:index, 19)
>     sleep 1
>     table[1][3].image(:name, "createbottom").click
>       assert($ie.contains_text($no_permission_msg)) !
>     $ie.link(:text,   "Settings").click();
>
>     end
>   end
>
>
> Any ideas?
>
> Thanks
>
> David
>
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
>

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to