5

Nor average, neither sum of percents. If some test methods cover one line of code twice, it only means that this exact line of code is covered. So the actual test coverage is linesCovered / allLines * 100. Example: imagine 1st test class covers one method in your controller (30%), 2nd test class covers 2 methods including the previous mentioned one (50%), ...


4

You have to query back the opportunity in order to see the value of the field. Since the value you are showing on the debug shows the value contained in the variable testOpportunity and not the value of the opportunity stored in memory(which was modified by the trigger). add a line after the update to update the value of the variable with the value stored ...


3

Two things I see here: If you want to evaluate changes to the opportunity, then you need to requery it after the OCR trigger has fired. ie, after your Test.stopTest(), requery the Oppportunity and then make your asserts. I don't see how your commented out System.assertEquals() statements about the contact lookups will ever be true, even after you requery. ...


2

I think that perhaps you can take an approach a bit more user friendly.. just a though. Giving the users the Insufficient privileges error. is not really a great experience. You can use your Constants Helper Class, if you have one... it not, is a good reason to start building one? Lest say you have your constants class with something like this: public ...


2

Are setup objects accessible in test classes regardless of SeeAllData attribute's value? Yes. A wide variety of setup objects are available in test context, as documented here: However, objects that are used to manage your organization or metadata objects can still be accessed in your tests such as: User Profile Organization AsyncApexJob ...


2

Hello it's because you did incorrect import of the component. In component definition you have export default ..., so you need to import import LWCpractice from 'c/lWCPractice'; instead of import { LWCpractice } from 'c/lWCPractice'; try this import { createElement } from "lwc"; import LWCpractice from 'c/lWCPractice'; describe("component 1", () => { ...


2

Set up records that need sharing in @testSetup. The share records will be visible for all unit tests after @testSetup completes. By using @testSetup, things that occur "after the transaction", such as record sharing, are created. Tests that use those records will then have access to those records. Confirmation @isTest class q293720 { @testSetup ...


1

You need to "construct" an instance of the controller, then call its methods. The constructor is the method with no return type and has the name of the class: public pairHouseholdController(ApexPages.StandardController controller) { This method wants an ApexPages.StandardController that has the account, so we need to do that first: ApexPages....


1

Your unit test attempts to execute the functionality under consideration by performing DML inserts and updates. However, your post does not contain - and your code coverage suggests you either do not have, or have failed to deploy - an Apex trigger. The classes TaskTrigger and CaseClass will not be called unless an active Apex trigger is present on the ...


1

The answer is yes. Got a super quick answer here: https://github.com/salesforce/sfdx-lwc-jest/issues/128 to use: https://github.com/MailOnline/jest-tap-reporter I couldn't get it to work just configuring in package.json but this did work: "scripts": { "test:unit": "sfdx-lwc-jest -- --reporters='jest-tap-reporter'" }, On reflection I'm going to use ...


1

Most records in an org are not visible to tests. You need to insert your own records in your test. Why? This makes tests self-contained rather than them relying on pre-existing data. It also usually makes assertions easier to write because the data values added are close at hand in the test. See e.g. Create Test Data for Apex Tests.


1

The global modifier doesn't change the fact that your execute() method is still an instance method. ClassName.method() is how static methods are called. Since execute() doesn't have the static modifier (and I don't think it should have that modifier anyway), you'll need to create an instance of your class to be able to call the instance method. e.g. ...


1

The JSON syntax for a list or array of strings (IDs are strings) is: ["string", "string", "string"] etc. The syntax "{...}" represents an object, which is different to an array. To simplify your case, I suggest your test set up an actual list and serialize to JSON, since this will automatically use the correct syntax. E.g.: Map<Id, SObject> ...


1

Your cache is an entirely separate mechanism. The passthrough itself would just grab the appropriate collection. protected override List<SObject> passthrough(List<SObject> records) { return cache.get(records.getSObjectType()); } Managing the cache itself isn't all that complicated. @IsTest public with sharing class QueryMock extends ...


1

The first things to look for when a trigger is not receiving coverage are Is the test passing? Is the trigger being invoked by performing the correct DML operation? Is the trigger active? Per your comment, this time the issue was that the trigger was inactive.


1

You can't create DML statements before calling your test API callouts. You should put all your DMLs in a separate function with a @TestSetup static Lead lead1; @TestSetup static void makeData(){ Lead lead = new lead( FirstName = 'Test First Name', LastName = 'Sample Last Name', Phone = '555-555-5555', ...


Only top voted, non community-wiki answers of a minimum length are eligible