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
Joshua MoodyJoshua Moody 

Console stuck on 0% Code Coverage

I am running up against a bug when testing the code provided in Trailhead "Getting Started with Apex Unit Tests".  I was working on the "VerifyDate" test and could not achieve any coverage.  So I copied the example "TemperatureConverter" and "TemperatureConverterTest".  That test also showed 0% coverage.  Anyone having the same issue?

Example:
public class TemperatureConverter {
    // Takes a Fahrenheit temperature and returns the Celsius equivalent.
    public static Decimal FahrenheitToCelsius(Decimal fh) {
        Decimal cs = (fh - 32) * 5/9;
        return cs.setScale(2);
    }
}


Example Test:
@isTest
private class TemperatureConverterTest {

    @isTest static void testWarmTemp() {
        Decimal celsius = TemperatureConverter.FahrenheitToCelsius(70);
        System.assertEquals(21.11,celsius);
    }
    
    @isTest static void testFreezingPoint() {
        Decimal celsius = TemperatureConverter.FahrenheitToCelsius(32);
        System.assertEquals(0,celsius);
    }

    @isTest static void testBoilingPoint() {
        Decimal celsius = TemperatureConverter.FahrenheitToCelsius(212);        
        System.assertEquals(100,celsius,'Boiling point temperature is not expected.');
    } 
    
    @isTest static void testNegativeTemp() {
        Decimal celsius = TemperatureConverter.FahrenheitToCelsius(-10);
        System.assertEquals(-23.33,celsius);
    }
      
}
 
Amit Chaudhary 8Amit Chaudhary 8
Please click on Run Test button top of your test class. and then check code coverage .
Joshua MoodyJoshua Moody
Thanks. Yes, I have run the tests.  I can see the tests have completed in the "Tests" tab in the Console.  However, code coverage does not change.
Amit Chaudhary 8Amit Chaudhary 8
Otherwise try to run test class from salesforce UI not from console and check
ManojjenaManojjena
Hi Joshua Moody,
Amit is right you should get 100 % coverage .Please go to test class and click on RunTest Button and click on class link and check .
 
Joshua MoodyJoshua Moody
Manoj and Amit,
Thank you.  Here is a screen of my test.  It ran successfully, but still shows 0% coverage.  I doublechecked on the class tab as well at the top.
Test ran successfully, but reports 0% coverage.
Joshua MoodyJoshua Moody
Success! Ran test from Salesforce UI instead of the Dev Console. Now shows test coverage at 100% on the example and the challenge.  Thanks again.