+ Start a Discussion
EalesieEalesie 

Picklist Bug - Unit Tests

I have tried to raise this via Support, but as its APEX generated it is classed as un-suported.  If anyone has come across this issue please let me know if you fixed the issue or just coded around.

 

I am inserting a value into a pickist field via Unit Tests Helper classes (see below) and this field is used by a BI/BU trigger to populate a unique field on the object via concatenation.

 

The issue is that when the unit tests for a class using this object is run in isolation the asserts pass correctly, however, when I run all tests 2 of the test methods using the helpers below fail.  I have tracked this down to the picklist field Lookup_Type__c being set to null somewhere between the insert command executing and the BI/BU trigger running.

 

I have coded around this in the trigger by checking for the picklist containing null and 'null' but I am not happy with this solution as I believe it to be a platform bug.

 

Any suggestions appreciated, also if anyone has succesfully raised a bug with Salesforce that exposed itself via APEX - how did you achieve it.

 

Many thanks

Ealesie

 

Unit Tests Helper methods being used.  This is the only way Transformation__c record are created during Unit Tests.

 

 

public static list<Transformation__c> CreateNewTransformations(String lookupType, Integer recCount)
{
list<Transformation__c> returnList = new list<Transformation__c>();
for (Integer iterator=0; iterator < recCount; iterator++)
{
returnList.add(GetNewTransformation(lookupType, 'LOOKUPVALUE' + iterator, 'RETURNVALUE' + iterator));
}
insert returnList;
return returnList;
}
public static Transformation__c CreateNewTransformation(String lookupType, String lookupValue, String returnValue)
{
Transformation__c newTrans = GetNewTransformation(lookupType, lookupValue, returnValue);
insert newTrans;
return newTrans;
}
public static Transformation__c GetNewTransformation(String lookupType, String lookupValue, String returnValue)
{
return new Transformation__c(Lookup_Type__c = lookupType,
Lookup_Value__c = lookupValue,
Return_Value__c = returnValue,
Lookup_Key__c = lookupType + lookupValue);
}

public static list<Transformation__c> CreateNewTransformations(String lookupType, Integer recCount) { list<Transformation__c> returnList = new list<Transformation__c>(); for (Integer iterator=0; iterator < recCount; iterator++) { returnList.add(GetNewTransformation(lookupType, 'LOOKUPVALUE' + iterator, 'RETURNVALUE' + iterator)); } insert returnList; return returnList; }
public static Transformation__c CreateNewTransformation(String lookupType, String lookupValue, String returnValue) { Transformation__c newTrans = GetNewTransformation(lookupType, lookupValue, returnValue); insert newTrans; return newTrans; }
public static Transformation__c GetNewTransformation(String lookupType, String lookupValue, String returnValue) { return new Transformation__c(Lookup_Type__c = lookupType, Lookup_Value__c = lookupValue, Return_Value__c = returnValue, Lookup_Key__c = lookupType + lookupValue); }