You need to sign in to do that
Don't have an account?
davidjbb
Test Case
Hello,
What's a good way to write test cases for fields that you've created within a class.
i've created alot of fields that are used on a VF page..I've already used all the methods within the Test case, but Salesforce shows a red line on the bolded.
My test method is also used within the same class.
so..
public with sharing class UMaterialController
{
private string test;
test = 'asdf';
etc..etc..
public string getTest()
{
return test;
}
static testMethod void UMaterialControllerTest(){
}
}
If you have specific logic that assigns values to your fields, you should call that logic in the test class and then assert that the values assigned to the fields are correct.
If there's no specific logic and you'd simply like to cover your fields-related code, call a setter method to set a value, then call the getter and assert that the value has been assigned. In your case:
controller.setTest('someValue');
System.assertEquals(controller.getTest(), 'someValue');
One more thing: don't use browser to run your unit tests, use the Force.com IDE instead. The browser doesn't correctly display the covered lines.
How would you do something like this.