You need to sign in to do that
Don't have an account?
bhanu_prakash
soql 101 at test class
Hi,
Iam getting error : soql 101 error on test class
Help me to fix these issue:)
Thanks for advance
Iam getting error : soql 101 error on test class
@isTest private class LastCommentComponentTest { @isTest static void publicOnlyTest(){ Case c = new Case(subject = 'apex test case'); insert c; CaseComment comment1 = new CaseComment(isPublished = false, parentId = c.id, commentBody = 'private apex test comment'); insert comment1; CaseComment comment2 = new CaseComment(isPublished = true, parentId = c.id, commentBody = 'public apex test comment'); insert comment2; CaseComment comment3 = new CaseCOmment(isPublished = false, parentId = c.id, commentBody = 'private apex test comment #2'); insert comment3; Test.startTest(); LastCommentComponent controller = new LastCommentComponent(); controller.caseId = c.id; controller.onlyPublic = true; CaseComment result = controller.getComment(); Test.stopTest(); System.assertEquals(result.id,comment2.id); } @isTest static void allTest(){ Case c = new Case(subject = 'apex test case'); insert c; CaseComment comment1 = new CaseComment(isPublished = false, parentId = c.id, commentBody = 'private apex test comment'); insert comment1; CaseComment comment2 = new CaseComment(isPublished = true, parentId = c.id, commentBody = 'public apex test comment'); insert comment2; CaseComment comment3 = new CaseComment(isPublished = false, parentId = c.id, commentBody = 'private apex test comment #2'); insert comment3; Test.startTest(); LastCommentComponent controller = new LastCommentComponent(); controller.caseId = c.id; controller.onlyPublic = false; CaseComment result = controller.getComment(); Test.stopTest(); System.assertEquals(result.id,comment3.id,'Got :'+result+' instead of '+[SELECT id, createdDate, commentBody FROM CaseComment WHERE id = :comment3.id LIMIT 1]); } @isTest static void noCommentTest(){ Case c = new Case(subject = 'apex test case'); insert c; CaseComment comment1 = new CaseComment(isPublished = false, parentId = c.id, commentBody = 'private apex test comment'); insert comment1; Test.startTest(); LastCommentComponent controller = new LastCommentComponent(); controller.caseId = c.id; controller.onlyPublic = true; CaseComment result = controller.getComment(); Test.stopTest(); System.assertEquals(null,result); } }
Help me to fix these issue:)
Thanks for advance
https://developer.salesforce.com/forums/?id=906F0000000AooRIAS
See below links that will help you to identify the issue.
https://help.salesforce.com/articleView?id=000181404&type=1
There is also a known issue with test classes due to process builder
https://success.salesforce.com/issues_view?id=a1p3A0000001C7cQAE