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

testmethod on @future
I have one method in a class that is designated as @future. How do I add test coverage for it? I'm getting "Save error: Test method cannot be marked as future"
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
I have one method in a class that is designated as @future. How do I add test coverage for it? I'm getting "Save error: Test method cannot be marked as future"
Test methods are no @future.
if you are trying to execute a test that call an @future class then place it within the test.startTest() and test.stopTest() code.
The future will run at the stopTest() call and then you can test for the results.
To clarify, given a function:
It would be tested as:
Does testDoSomething need to be in the same or a separate classe?
I'm also trying to create an AppExchange package and I'm getting this ...
Does testDoSomething need to be in the same or a separate classe?
It doesn't matter. Put it where you will. Some developers like the "all-in-one" approach to testing (fewer classes), some like "separation of testing" (more classes that are smaller).
I'm also trying to create an AppExchange package and I'm getting this ...
My code coverage is still very low. This is what I've added to my GetPostData class...
public with sharing class GetPostData {
@isTest
public static void testDoSomething() {
Test.startTest();
execute();
Test.stopTest();
}
@future(callout=true)
public static void execute() {
...
all logic is in here including some http callouts
...
}
} //end class
I have 7 or 8 classes like this structured in the exact same format.
Thanks for all of the help.