From: Aldric Giacomoni Date: 2010-04-13T22:00:47+09:00 Subject: Re: Newbie: Control flow of tests using 'define_method' Chris Cropleu wrote: > class TestSuite < Test::Unit::TestCase > > #Build a hash of Source Database columns and target Database columns > > companyRRAccessToBeacon = Hash.new > companyRRAccessToBeacon['company_id'] = 'ID' > cmpanyRRAccessToBeacon['ultimate_parent_id'] = 'GlobalUltimateID' > companyRRAccessToBeacon['fullname'] = 'Name' > companyRRAccessToBeacon['turnover_curr'] = 'TurnoverCurrencyTypeID' > companyRRAccessToBeacon['turnover'] = 'TurnoverAmount' > companyRRAccessToBeacon['u_size_code'] = 'CorporateSizeTypeID' > companyRRAccessToBeacon['corp_status_id'] = > 'CorporateOwnershipTypeID' > companyRRAccessToBeacon['created_user'] = 'RowCreatedBy' > companyRRAccessToBeacon['created_datetime'] = 'RowCreatedDate' > companyRRAccessToBeacon['last_modification_by'] = 'RowModifiedBy' > companyRRAccessToBeacon['last_modification_date'] = > 'RowModifiedDate' > companyRRAccessToBeacon['off_limits_id'] = 'OffLimitsID' Wowzer. How about this? companyRRAccessToBeacon = {'company_id' => 'ID', 'ultimate_parent_id' => 'GlobalUltimateID' } And so on and so forth ? A little cleaner, a little easier to read, fewer repetitions. > > #Connect to the RRAccess and Beacon databases > rraccesshandle = connectrraccessdb > beaconhandle = connectbeacondb > > [...] > > #Loop through each record returned in the Data Driven Test set. > companyrowData.each do | companydata | > puts "In #{companydata} loop" > #If no Company records are returned then run the test. > companydata["company_id"] != "" > recordtofetch = companydata["company_id"] Where is your if statement? Maybe you mean this? recordtofetch = companydata['company_id'] unless companydata['company_id'].empty? > [...] > > > The output of this is as follows: > [...] > Inside assert_equal loop for test_company_CorporateOwnershipTypeID > FInside assert_equal loop for test_company_CorporateSizeTypeID > FInside assert_equal loop for test_company_GlobalUltimateID > .Inside assert_equal loop for test_company_ID > .Inside assert_equal loop for test_company_Name > .Inside assert_equal loop for test_company_OffLimitsID > FInside assert_equal loop for test_company_RowCreatedBy > .Inside assert_equal loop for test_company_RowCreatedDate > .Inside assert_equal loop for test_company_RowModifiedBy > .Inside assert_equal loop for test_company_RowModifiedDate > .Inside assert_equal loop for test_company_TurnoverAmount > .Inside assert_equal loop for test_company_TurnoverCurrencyTypeID > F > Finished in 0.029 seconds. > > 1) Failure: > test_company_CorporateOwnershipTypeID(TestSuite) > [C:/Users/ecucropc/Documents/Visual Studio > 2008/Projects/DataSynchronisation/DataSynchronisation/CommonTest.rb:57]: > <"QUO "> expected but was > <1>. Well, in your first test, you get a '1' back and you apparently expect a "QUO ". Anything else the errors can tell you that they can't tell us? Look into this and get back to us a little later.. The tests work, they're telling you that they fail :) -- Posted via http://www.ruby-forum.com/.