You need to sign in to do that
Don't have an account?
BrettB
test method assistance
Im hitting my head against the wall and need some assistance... in regards to a test method...
Im trying to add a button to my production environment, that uses a controller to run some apex and move a S2S opportunity into a partner account.
The problem is i have ZERO percent coverage...below is my code...I know its bad, bu im just starting at this testMethod thing...Please help with what im missing,
Following is my controller and test method
public class VFController { private final Opportunity o; public VFController(ApexPages.StandardController stdController) { this.o = (Opportunity)stdController.getRecord(); } // Code we will invoke on page load. public PageReference autoRun() { String theId = ApexPages.currentPage().getParameters().get('id'); if (theId == null) { // Display the Visualforce page's content if no Id is passed over return null; } for (Opportunity o:[select id from Opportunity where id =:theId]) { PartnerNetworkRecordConnection newConnection = new PartnerNetworkRecordConnection( connectionId = '04PM0000000CaRqMAK', LocalRecordId = o.Id); insert newConnection; } // Redirect the user back to the original page PageReference pageRef = new PageReference('/' + theId); pageRef.setRedirect(true); return pageRef; } static TestMethod void test() { List<PartnerNetworkRecordConnection> pncs = new List<PartnerNetworkRecordConnection>{}; for (Opportunity o:[select id from Opportunity]) { PartnerNetworkRecordConnection pnc = new PartnerNetworkRecordConnection ( connectionId = '04PM0000000CaRqMAK', LocalRecordId = o.Id); pncs.add(pnc); insert pnc; List<PartnerNetworkRecordConnection> insertedPncs = [select connectionId, localrecordId from PartnerNetworkRecordConnection where Id in :pncs]; } } } |
try this
Add one more for better coverage
All Answers
Your test method should be like
It should increase your code coverage, Please asserty your result in this test method
ThankYou plenty for helping out...
Good news i have 53 coverage...
Bad news i need 75...
I added the code below and got this error when running the test
System.NullPointerException: Key value cannot be null
When I remove the line totoaly test= success but only 53 coverage
Here is the code implimented:
Please advise at your convenience .
b
try this
Add one more for better coverage