You need to sign in to do that
Don't have an account?
domdick
Need help with test coverage on apex class
Hello,
I have apex controller to check if opportunity has a pricebook associated yet or not. It works fine as user point of view but strugling to make a test class for this.
Much appriciate any help with an example!
thanks
Yes, I had this problem as well when working with PriceBooks. I usually use seeAllData=true and use the existing records to simplify things. Make sure that the records that you are using in the SandBox also exist in Production....
Happy Friday,
Adrian
Thanks Adrian for the inupt on this.
Here is the test but still doesn't get full coverage.
I am sure something missing, so further help required. Thanks,
Add below line to your code :-
as you are not testing priceBookCheck() method in your test class.
i have already tried to add this line with other test but it doesn't cover the following lines from initial test...
any other ideas?
Well, this all seems to be related to the your specific test data. You need to set up testing conditions for all your if branches... You could use the the viewalldata annotation only for one case, and create a new test method that doesn't have that one and build your own test data.
For the :
part you could make that forcepricebookselection public and set it to different values from your test method before running its related method.
Happy Monday!
Adrian