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.
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:
- Check Class Name: Ensure the class is named TemperatureConverterTest exactly as expected, including correct capitalization.
- 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
@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Ü
@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
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Ü