You need to sign in to do that
Don't have an account?
how can you test a class of utility methods that simply pass parms back and forth?
How do you create a test class over a utility class when the methods are pretty much all just passing parms back and forth? For example I have a method that gets passed a name field and the method just does some formatting like first letter upper case the rest of each word lower case, etc. finally it passes the name back.
Since tests are all static.
Thanks for the help.
Since tests are all static.
Thanks for the help.
class MyClass_Test {
static testmethod void myTestMethod() {
Test.startTest();
myClass mc = new myClass();
string sIShouldGetThis;
string sIGotThat;
sIShouldGetThis = '123'
sIGotThat = mc.MyMethod();
// repeat the above for every method in the class.
Test.stopTest();
System.assertEquals(sIShouldGetThis, sIGotThat);
}
}
All Answers
class MyClass_Test {
static testmethod void myTestMethod() {
Test.startTest();
myClass mc = new myClass();
string sIShouldGetThis;
string sIGotThat;
sIShouldGetThis = '123'
sIGotThat = mc.MyMethod();
// repeat the above for every method in the class.
Test.stopTest();
System.assertEquals(sIShouldGetThis, sIGotThat);
}
}
how do I get my beginning varialbe sHereIsWhatIHave passed into my test method
In the example, the method in the program does not take parameters. It just give some value.
If you need ot pass a variable into the method in your program - then make one up and pass it in.
Then compare what you get with what you think - this done in the assert.
Thanks so much for the help
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@isTest
class RciService_Test{
static testMethod void vldt_capitalizeFirstLetters(){
Test.startTest();
string sThisIsWhatIHave = 'FIRST name o\'maLLY';
string sIShouldGetThis;
string sIGotThat;
sIShouldGetThis = 'First Name O\'Mally';
sIGotThat = RciService.capitalizeFirstLetters(sThisIsWhatIHave);
System.debug('this-' + sIshouldGetThis + ' and That-' + sIGotThat);
Test.stopTest();
System.assertEquals(sIShouldGetThis, sIGotThat);
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++