How To Check Different Assert Methods in this code?

public with sharing class AssertEx 

 public integer sum()

         integer a =10;

         integer b =20;

         integer c;






         return c;


  • You need to write the test code and assertions inside a test class/method, not in the actual class. – Boris Bachovski Jan 27 '16 at 5:20

You should google articles before posting anything here.

Have you looked at this article? https://developer.salesforce.com/forums/?id=906F00000008x42IAA

Anyways, here are your asserts:

| improve this answer | |
  • I declare this values are these right values? System.assertequals(30,c); System.assertNotEquals(20,c); – Bonny Jan 27 '16 at 5:22
  • Why don't you give them a try in your code? You will get a better understanding. And yes they are correct. – Salesforcesmarty Jan 27 '16 at 5:25
  • This should be System.assertEquals(10, a); and same for NotEquals. expected, then actual. – Charles Koppelman Jan 27 '16 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.