function [classindex, storeprob] = test_class(dbroot, testclassname, trainingclasses, threshold)

global RIS;

fprintf(1,'TESTING STARTING...\n')     

%test for correct arguments
if(size(testclassname,1) > 1)
    error('Error - argument %s invalid - can only test one class at a time', testclassname);    
end

%the test class file - this should already by collected
testclassdata = [dbroot '/' testclassname '_data_collection_avljNL3_cl_pcsnew' '.mat']; 
testclassfiles = [dbroot '/' testclassname '_image_file_metadata' '.mat'];


%load and init test class data
if(~exist(testclassdata))
    error('Error - file %s does not exist', testclassdata);
end
if(~exist(testclassfiles))
    error('Error -  file %s does not exist', testclassdata);
end
load(testclassdata); 
tcd = classdata;
load(testclassfiles);
tcf = classfilemetadata;

%initialize the classifier with the training classes
init_classifier(dbroot, trainingclasses);

%calculate random indexes using the length of the test class
randomindex = randperm(length(classfilemetadata));

%pick 10% of random index to use for testing
numtest = round(length(classfilemetadata)*0.10);
indxtst = randomindex(1:numtest);

%init testing parameters
scale = 3;
Thres = 0.9; %threshold;


%test classes aganst training classes
[CM, recfiles, sp, ci] = test_ljmNL3 (trainingclasses, tcd(indxtst,:), tcf(indxtst,:), RIS, scale, Thres);

classindex = ci;
storeprob = sp;

fprintf(1,'TESTING DONE...\n')     

end
