Skip to main content TDX, the developer conference for the AI agent era is happening now. Watch live on Salesforce+ for exclusive digital content, a revolutionary keynote, and more.

i cant find the errors for this  topic

here's the courses : Premiers pas avec les tests unitaires Apex | Salesforce Trailhead

Errors on my editor : 

This class name's value is invalid: TemperatureConverterTest. Provide the name of an Apex class that has test methods.

 

#Trailhead Challenges

5 个回答
  1. 2024年10月24日 15:15

    Hello @El mehdi AIT TALBALI,

    The error "This class name's value is invalid: TemperatureConverterTest" usually means that the class doesn't have any valid test methods or the name is not correctly set up.

    To resolve this:

    1. Check Class Name: Ensure the class is named TemperatureConverterTest exactly as expected, including correct capitalization.
    2. Add Test Methods: Make sure the class contains test methods annotated with @isTest. For example:

    @isTest

    private class TemperatureConverterTest {

    @isTest

    static void testCelsiusToFahrenheit() {

    // Your test logic here

    }

    }

    Save and Compile: After making changes, save and compile the class again. 

     

    Regards

    Sunny Patwa

  2. 2024年10月28日 09:26

    @El mehdi AIT TALBALI try to use English as a main language for your Trailhead website and for your SF Org.

     

    Also too, you can compare your steps with steps provided in this video

     

    Sincerely, 

    Mykhailo Vdovychenko 

    Bringing Cloud Excellence with IBVCLOUD OÜ 

  3. 2024年10月28日 09:18

    @Mykhailo Vdovychenko i used the methods but still have the same error 

    This class name's value is invalid: TestVerifyDate. Provide the name of an Apex class that has test methods.

    thank you in advance if you have an alternative to solve this problem 

  4. 2024年10月24日 21:18

    Hi, @El mehdi AIT TALBALI

     

    For this Challenge you can use this code:

    @isTest

    private class TestVerifyDate {

    // This test checks if firstDate <= secondDate

    // because this is true, testDate (expected) and resultDate (actual) should be true

    @isTest static void testCheckDates() {

    Date firstDate = date.newInstance(2023, 01, 02);

    Date secondDate = date.newInstance(2023, 02, 11);

    Date resultDate = VerifyDate.CheckDates(firstdate,secondDate);

    Date testDate = Date.newInstance(2023, 01, 31);

    System.assertEquals(testDate,resultDate);

    }

    // This test checks if secondDate <= 30days from firstDate

    // because this is true, testDate (expected) and resultDate (actual) should be true

    @isTest static void testDateWithin30Days(){

    Date firstDate = date.newInstance(2023, 01, 20);

    Date secondDate = date.newInstance(2023, 02, 11);

    Date resultDate = VerifyDate.CheckDates(firstdate,secondDate);

    Date testDate = Date.newInstance(2023, 02, 11);

    System.assertEquals(testDate,resultDate);

    }

    // This test checks if VerifyDate.CheckDates() returns false

    // which would trigger private method SetEndOfMonthDate()

    @isTest static void testEndofMonthDate(){

    Date firstDate = date.newInstance(2023, 01, 02);

    Date secondDate = date.newInstance(2023, 02, 11);

    Date resultDate = VerifyDate.CheckDates(firstdate,secondDate);

    // Cannot use private class method for testing so the following fails

    // Date resultDate = VerifyDate.SetEndOfMonthDate(firstdate);

    Date testDate = Date.newInstance(2023, 01, 31);

    System.assertEquals(testDate,resultDate);

    }

    }

    I wish you success in your further learning Salesforce.

     

    Sincerely, 

    Mykhailo Vdovychenko 

    Bringing Cloud Excellence with IBVCLOUD OÜ

  5. Smitha Thomas (CIBC) Forum Ambassador
    2024年10月24日 15:19

    Hi @El mehdi AIT TALBALI,

     

    Make sure you copy paste the code correctly from the unit.

0/9000