testbox newbie

Hey all,
so i have added testbox into our cf11 testbox that has a CB 2.6.3 setup on it. I am trying to test a basic search cycle. we have a handler that sets some stuff up, then calls the model function which brings data back to a jqgrid. I am not sure if my testbox function should call the handler or just the model…i hope i can test this through the handler…if so my handler could possibly be weird so i need some help. so here is the code:

component extends=“testbox.system.testing.BaseSpec”{

function run(){
describe(“A suite”, function(){
beforeEach(function() {
handler = createObject(“component”,“handlers.ehlcjrExternal”);
event = createObject (“coldbox.system.beans.requestContext”);
coldbox = 22;
});

it(“can have more than one expectation and talk to scopes”, function() {
expect( coldbox ).toBe( 22 );
});

it(“should return data for the grid”, function(){

//this setting up the object
businessHandler = handler.dspQuickJobOrderSearchGridData(event);

expect( businessHandler ).isGT( 0, ‘This returned 0 records’);
});
});
}
}

below is the handler function:

var rc = Event.getCollection(); //Init profile Object var objLCJRExternal = instance.lcjrExternal; var objLCJRUtil = instance.lcjrUtil; Var case_number = ""; var create_date = ""; var employer_business_name = ""; var job_title = ""; var status_id = ""; var post_end_date = ""; var startSearch = ""; var state = ""; var state_id = ""; var visa_class_id = ""; var naic_code = ""; var naic_title = ""; rc.qryCases = ""; startSearch = event.getValue("startSearch",''); case_number = event.getValue("case_number",''); employer_business_name = event.getValue("employer_business_name",''); visa_class_id = event.getValue("visa_class_id",''); status_id = event.getValue("status_id",''); state_id = event.getValue("state_id",''); location_range = event.getValue("location_range",''); location_zipcode = event.getValue("location_zipcode",''); job_title = event.getValue("job_title",''); create_date = event.getValue("create_date",''); post_end_date = event.getValue("post_end_date",''); state = event.getValue("state",''); naic_code = event.getValue("naic_code",''); naic_title = event.getValue("naic_title",'');

rc.strZipCodePassed = objLCJRUtil.getZipCodesNearby(location_zipcode,location_range);

rc.qryCases = objLCJRExternal.getQuickJobOrderSearchGridData(rc.page,rc.rows,rc.sidx,rc.sord,startSearch,case_number,employer_business_name,visa_class_id,status_id,state_id,job_title,create_date,post_end_date,state,naic_code,naic_title,rc.strZipCodePassed);

event.renderData(type=“JSON”,data=rc.qryCases);

I have had issues with the event passing in, then the instance var was a problem…so from checking my code above, can i test this the way I want to, or do I have to do some crazy stuff to get this to work? We have much crazier handler functions than this, but the event and instance is part of all our functions…

Any thoughts on this as I try to learn testbox?

thanks
Dan

I am confused, are you trying to unit test your handler or do an integration test?

What are you trying to accomplish, a top-down test or just the handler source code?

trying to do a top down test…
we have a search page that users put in criteria and then when click search goes through the handler to the model, runs the search query and comes back with results. The handler file has a cfproperty at the top and then uses instance.propertyName in the actual function call…i did not write the function.

I know this code better than other parts of our system so thought i’d start in a familiar area before i get into the area of user login.

I get an error for the insatance var…i figure i need to do some mocking to mock up the cfproperty tags so this will work…does the code above with the instance. then work if the cfproperty tag is mocked?

I wish this code was simple but it is not…i know i probably should just create a simple site to learn testbox but i thought this was simple :slight_smile:

I can create mxUnit tests but want to do bdd style stuff…

thanks
dan