function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kishore B TKishore B T 

How to set values in multiselect picklist in testclass


The Below is the code for getting Multiselect picklist. Currently its returning null when i Run test class.
Page
<apex:pageBlockSectionItem > <b> Category </b>
 <apex:outputPanel > <div class="requiredInput">
<div class="requiredBlock"></div>
 <apex:selectList value="{!Category}" required="true" size="4" id="CatG" multiselect="true"style="width:120px;">
<apex:selectOptions value="{!listcategory}"/>
 </apex:selectList> </div> </apex:outputPanel>
</apex:pageBlockSectionItem>


Class
public List<string> Category{ get; set; }
public List < SelectOption > listcategory{ get; set; }
Schema.DescribeFieldResult fieldResult = MasterItem__c.Type__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple) {
listcategory.add(new selectOption(f.getLabel(),f.getValue()));
}
Where as the the MasterItem__c.Type__c contains the values like
Actives,Passives,Misc and others

My Complete Controller runs on this snippet if its covered then my class will cover 100%.
So some one can let me know how to Pass the Above values into the Category field.
I need that category field to have in this main query.
for (VendorItem__c v: [SELECT Id, BillTo__r.City__c, BillTo__r.Country__c, BillTo__r.PostalCode__c, BillTo__r.State__c, BillTo__r.Street__c, CurrencyIsoCode, DeliveryTerms__c, DeliveryTimeline__c, DocumentationRequirement__c, IsPrefferedVendor__c, IsRecentSupplier__c, Make__c, MasterItem__c, MasterItem__r.Stock__C, ModeofPayment__c, Name, PackagingType__c, Price__c, PriceType__c, Remarks__c, ShippingMode__c, ShipTo__r.City__c, ShipTo__r.Country__c, ShipTo__r.PostalCode__c, ShipTo__r.State__c, ShipTo__r.Street__c,SPQ__c, UnitofMeasurement__c, vendorname__c, Package__c, (SELECT id FROM BOM_Line_Items__r) FROMVendorItem__c WHERE IsRecentSupplier__c=true AND MasterItem__c=:mapProductItems.keyset() AND MasterItem__r.type__c=:Category