You need to sign in to do that
Don't have an account?
![Alena Semenova 14 Alena Semenova 14](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Hello! Tell me how to write a test for this method? Thank you!
testItemList = [SELECT Id, Right__c, Percent_correct_answers__c FROM Session__c WHERE Id =:SessionId]; //update field Answer for Session if (newItem[0].Answer__c == answer) { answerCount++; testItemList[0].Right__c=answerCount; update testItemList; }
Try below code sample test class
@isTest
public class yourClass_Test {
@TestSetup
static void setupdata() {
//first insert one Session__c record
Session__c sc= new Session__c (name=''.........);
insert sc;
}
static testMethod void testcase() {
//Query the Session__c record
Session__c screc = [SELECT Id from Session__c LIMIT 1];
//call your class here and pass screc.Id
-----
---
}
}
hope this helps your porblem.