You need to sign in to do that
Don't have an account?
Regarding Test Class(showing No code coverage)
public class BMGlobal {
public static final String Test1= 'Test1';
public static final String Test2 = 'Test2';
public static final String Test3 = 'Test3';
}
@istest
Private class BmglobalTest{
Static testmethod void bm()
{
String s1 =BMGlobal.Test1;
String s2 =BMGlobal.Test2;
String s3 =BMGlobal.Test3;
system.assertEquals(s1,'Test1');
system.assertEquals(s2,'Test2');
System.assertEquals(s3,'Test3');
}
}
We have to write test class for Above Class.
Below one is Test class. while runnig test class we are not getting error but code covergae is 0.
Can you please help me how to increase code coverage.
Thanks in Advance
Nikhil
i just put constructor inside class.
in test class just make an instence of class and it worked.
Thanks all of them for reply
All Answers
Try this
public class BMGlobal
{
public static final String Test1= 'Test1';
public static final String Test2 = 'Test2';
public static final String Test3 = 'Test3';
}
Private class BmglobalTest
{
Static testmethod void bm()
{
BMGlobal b = new BMGlobal();
String s1 =b.Test1;
String s2 =b.Test2;
String s3 =b.Test3;
system.assertEquals(s1,'Test1');
system.assertEquals(s2,'Test2');
System.assertEquals(s3,'Test3');
}
}
Regards,
Magulan D
Salesforce.com certified Force.com Developer.
SFDC Blog
If this post is your solution, kindly mark this as the solution.
I tried it and am getting 100% code coverage. This is the code:
public class BMGlobal{
public static final String test1 = 'Test1';
public static final String test2 = 'Test2';
public static final String test3 = 'Test3';
}
@isTest
private class Test_BMGlobal{
static testMethod void unitTest(){
string s1 = BMGlobal.Test1;
string s2 = BMGlobal.Test2;
string s3 = BMGlobal.Test3;
system.assertEquals(s1,'Test1');
system.assertEquals(s2,'Test2');
system.assertEquals(s3,'Test3');
}
}
I tried the same thing as you worte. but the code coverage is still 0 and when i remove 'final' from class then code coverage increase to 100 %.
Can you please tell me why the class has no covergae when we use 'Final' keyword inside class.
Thanks
Nikhil
i just put constructor inside class.
in test class just make an instence of class and it worked.
Thanks all of them for reply