You need to sign in to do that
Don't have an account?
Alex.Acosta
Getting Code Coverage on 'final' classified variables?
I have a constant variable class for parsing out xml stucture on callouts as seen below. Problem is the way code is covered has changed it seems. Any idea why and/or how to fix this?
public with sharing class XMLElementNodeNames {
public static final String CATEGORY_TAG = 'category';
public static final String CATEGORIES_TAG = 'categories';
public static final String ID_TAG = 'id';
public static final String SCORE_TAG = 'score';
...
static testmethod void testAll() {
// only having the following line would cover the class. Now it returns with 0% coverage
XMLElementNodeNames x = new XMLElementNodeNames();
// I have since added the following to try for code coverage to no avail.
String theString;
theString = CATEGORY_TAG;
theString = CATEGORIES_TAG;
theString = ID_TAG;
theString = SCORE_TAG;
....
}
}
public static final String CATEGORY_TAG = 'category';
public static final String CATEGORIES_TAG = 'categories';
public static final String ID_TAG = 'id';
public static final String SCORE_TAG = 'score';
...
static testmethod void testAll() {
// only having the following line would cover the class. Now it returns with 0% coverage
XMLElementNodeNames x = new XMLElementNodeNames();
// I have since added the following to try for code coverage to no avail.
String theString;
theString = CATEGORY_TAG;
theString = CATEGORIES_TAG;
theString = ID_TAG;
theString = SCORE_TAG;
....
}
}
During code Code coverage - we have to write a test class that has dummy records inserted (based on how the class will be called) - which in turn should call this class and methods.
Regards,
Ashish