You need to sign in to do that
Don't have an account?

can we cover this boolean property should render=true and should render=false in test class?
public Boolean shouldRender{get;set;}
if (loc == 'Visibility') {
shouldRender = false;
} else if(loc == 'Ownership'){
shouldRender = true;
}
yes it is possible,
In your test class define two different test methods
set loc variable 'Visibility ' and 'OwnerShip' in two different scenario,
you need to create two scenario here
Thanks,
Bala
how to declare that loc variable in test class
Write two test methods in your test class and assign loc = 'Visibility' in one method and loc = 'OwnerShip' in another one.
You wouldn't declare the loc variable in the test class, as you need to set the value of the loc variable in the class that you are testing.
Its a little tricky to tell without seeing your entire class, but assuming that the code you have posted is part of a method similar to that shown below:
You'll need a test something like this:
Bob,
Click on the poster's user name; they have several posts in regards to this class they're attempting to get working, a whole handful of them. I commented on one, and that one has the full class. Maybe you can help out further.
Tryout the below sample code :
@isTest
private class TestVolunteerRegistration
{
static testMethod void testRunAs1()
{
sa_volunteer_registration VolReg = new sa_volunteer_registration();
// You can cover the loc = "visbility" here....
}
static testMethod void testRunAs2()
{
sa_volunteer_registration VolReg = new sa_volunteer_registration();
// you can cover the loc = "Ownership" here...
}
}
Hope this helps.