I have a Enum class as:

global class Util {
global enum Session {

and a test class as :

private class Util_Test{
public static testmethod void callTestData(){
    Util.Session se = Util.Session.Winter;

But still my code coverage is 0%?? Why.

Also I tried many ways to cover it but not able to can any one help!!


I'm guessing that this has either something to do with Eclipse if that's where you're testing it, or something to do with the browser-based testing. You could check to see if the class is still listed as Valid in the develop/classes section of the standard UI. But I just ran a test and get 100% coverage.

You might try recompiling all classes through the interface as well. And if this is showing 0% in Eclipse, you could also recreate your project fresh (with a different name) since sometimes local projects become corrupt. But your code is fine.

enter image description here

| improve this answer | |
  • I am running it from UI and I also did the compile all action but still I am getting 0% coverage. Also checked in developer console but it still is 0% – user614946 Nov 21 '13 at 5:29
  • I just tested in the console and through the UI and both are 100%. Could you have different API versions between test class and Util? Since they're small, try re-creating both of them with different names and verify that it works. Otherwise you might have an issue in your instance that I'm not seeing. I'm seeing no problems on na15. – Adam Nov 21 '13 at 5:43
  • I am also on Na15 and yes the version were different but I changed both to 29.0 but still the same code coverage – user614946 Nov 21 '13 at 6:02
  • Also you didn't post your entire test class, just that method. If you created two new classes exactly as I have them, you'll get 100% coverage. Then compare with yours and see what's different. – Adam Nov 21 '13 at 6:48
  • Edited the post and that is my full class.. my question is I have version as 29 and class is same as you said then why it is 0% – user614946 Nov 21 '13 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.