New answers tagged

0

You only need to create single mock for Class A and then when you run your unit test for class B when it comes to HTTP Callout part in class A it will do that mock. 1) Class B calls method from Class A with Callout 2) When test comes to HTTP Callout it will implement the mock 3) Unit test continues as usual. I hope this helps you.


0

You can write one test class for class B and you need to include mock class where you need to specify the response inside mock class. Include this in test class and run this and confirm the code coverage. This is enough for deployment to Production. Hope it answer your question!!


1

For tooling API you should do a REST Explorer get request. On utility tab select Rest Explorer select GET. /services/data/v46.0/tooling/query/?q=SELECT ApexClassOrTrigger.Name, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate You will get the resuls, But this seems not so friendly, this will not solve your Problem. To get the .csv of ...


0

We have been using the UserInfo.isMultiCurrencyOrganization() method in our code to ensure that we dont get compile/runtime error for our managed package code.


0

Json string does not looks good. Try to place the json string in Static Resource and json string should be the following as per your apex code. String fullJson = '{"results":"your Json Response"}';


0

String fullJson = 'your Json Response'; You must change this line to valid JSON. You can use the timesheetData class to help build the appropriate JSON string using JSON.serialize.


0

Actually the motive of test class is not to cover your functionality. Use of Test class. The test class is generally used to test your actual functionality. the test class is checking Expected results with Actual results. Please check this module to explore more about test class Test class Trailhead Now come to your problem. You do not create any test ...


1

A System.UnexpectedException looks like a gack. This is one you'll need to create a ticket for at help.salesforce.com using the error Id as a reference.


0

I faced similar problem in my test class which is covering one batch class which is running on user. The problem is when you are running a test class only one time execute method should execute. So when you are executing the batch class. please increase the batch size like below code. static testMethod void testBatch(){ test.startTest(); ...


0

My solution was to simply NOT HAVE AN AGENT WORK TRIGGER! Put all your logic in a separate class. Now annotate the entry method with @InvocableMethod and call that method from the Process Builder. BAM! No more AgentWork trigger, no more requirements for test coverage, no more errors about FIELD_INTEGRITY ServiceChannelId bunk, no more logging into Omni-...


0

This is a very interesting scenario, which everyone faced while testing/deploying omnichannel. Inserting is not allowed and as manish porwal suggested you have to make test running user as active on OmniChannel to get coverage for AgentWorkTrigger. This makes unit testing hard and impossible for CI/CD as someone has to manually go and make test running user ...


0

I have faced the similar situation in my test class related to AgenWorkTrigger. To have a successful run for the test class, the logged in user should be available on the omnichannel and after that test class should be run.


2

Your unit test is failing because the owner ID did not change. You assigned it to the queue too early: Case c = new Case(); c.ownerId = q.QueueId; c.RecordTypeId = WmgRecordTypeId; insert c; Instead, allow the owner ID to be the current user on insert: Case c = new Case(); // c.ownerId = q.QueueId; // Remove this line c.RecordTypeId = WmgRecordTypeId; ...


1

You declare demoGoods locally, then you assign it and return it. But you never touch the RestContext.response in order to set it there. Your test expects you to do so. DemoGoods = Database.query(qryString); // here you need to set RestContext.response.responseBody return DemoGoods; Most likely, you will just serialize your records. RestContext.response....


Top 50 recent answers are included