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
Michel M.Michel M. 

Test Coverage Issue ...

Hello Guys,

I have spent a few hours developping a simple code, and now I am facing serious problem deploying that code. I really don't understand why my Class is not covered by the test I am running ...

I have a test method like this which creates two Accounts, right ?

Code:
public class TMSBUTopLevel {
public static testMethod void mytest(){
Test.startTest();
Account a = new Account(name='test');
Account b = new Account(name='test2');
a.Owning_Organization__c='test-test';
insert a;
insert b;
Test.stopTest();
}
}

 And the creation of these two accounts should fire following trigger, still right ?

Code:
trigger accountSBUIns on Account (before insert) {
Account[] testAcc = Trigger.new;
accountSBU.registerSBU(testAcc);
}
Which should call the method in this class :

Code:
public class accountSBU {
public static void registerSBU(Account[] accgr){
for(Account a:accgr){
String[] sbuLevels = a.Owning_Organization__c.split('-');
if(sbuLevels[0].equals('ENGR') || sbuLevels[0].equals('FIN') || sbuLevels[0].equals('FS&RE') || sbuLevels[0].equals('HR') ||sbuLevels[0].equals('IT&S') ||sbuLevels[0].equals('LEGL') ||sbuLevels[0].equals('S&L')){
sbuLevels[0]='Function';
}
if(sbuLevels[0].equals(' ') || sbuLevels[0].equals('') || sbuLevels[0]== null){
sbuLevels[0]='Not Defined';
}
a.Owning_SBU_Org__c = sbuLevels[0];
}
}
}
But for an unknow reason, when I run the test my coverage results only "covers" the trigger ....
Code Coverage is 100% but only for the trigger ...
No information for my class ... and when I try to deploy it, then it tells me that my class is not covered enough.

Any help or ideas would be appreciated.

Regards,
Michel