You need to sign in to do that
Don't have an account?
cl0s3r
ApexPages.Mesages Test Coverage
How can I cover the following code via test data?
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM, 'The case status is not in a valid state'); ApexPages.addMessage(myMsg); return ApexPages.currentPage();
You don't need to write any thing extra for this this will get covered when the actual method that contains it will be called. Is that code in a Catch block?
It isnt in a catch block it is in an if statement. The code isnt getting covered via the test though.
Maybe the best question then should be, How do you test both logical branches?
In that case you need to create data in such way that your logical branch which has this code gets executed. If you can provide me your class and test class code, then I can help you in creating such test case to cover it.
Class