Test class and test coverage in salesforce

36 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€47.51
List Price:  €66.52
You save:  €19
£39.57
List Price:  £55.40
You save:  £15.83
CA$69.83
List Price:  CA$97.77
You save:  CA$27.93
A$76.76
List Price:  A$107.48
You save:  A$30.71
S$67.19
List Price:  S$94.07
You save:  S$26.88
HK$389.07
List Price:  HK$544.73
You save:  HK$155.66
CHF 44.17
List Price:  CHF 61.85
You save:  CHF 17.67
NOK kr552.55
List Price:  NOK kr773.61
You save:  NOK kr221.06
DKK kr354.40
List Price:  DKK kr496.19
You save:  DKK kr141.78
NZ$85.21
List Price:  NZ$119.31
You save:  NZ$34.09
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳5,978.91
List Price:  ৳8,370.95
You save:  ৳2,392.04
₹4,225.77
List Price:  ₹5,916.42
You save:  ₹1,690.64
RM223.20
List Price:  RM312.50
You save:  RM89.30
₦84,012.69
List Price:  ₦117,624.49
You save:  ₦33,611.80
₨13,908.54
List Price:  ₨19,473.08
You save:  ₨5,564.53
฿1,733.10
List Price:  ฿2,426.48
You save:  ฿693.38
₺1,727.24
List Price:  ₺2,418.28
You save:  ₺691.03
B$290.46
List Price:  B$406.67
You save:  B$116.21
R906.09
List Price:  R1,268.60
You save:  R362.51
Лв92.91
List Price:  Лв130.09
You save:  Лв37.17
₩70,046.43
List Price:  ₩98,070.61
You save:  ₩28,024.17
₪186.68
List Price:  ₪261.37
You save:  ₪74.69
₱2,952.60
List Price:  ₱4,133.88
You save:  ₱1,181.28
¥7,718.58
List Price:  ¥10,806.63
You save:  ¥3,088.05
MX$1,017.02
List Price:  MX$1,423.91
You save:  MX$406.89
QR182.44
List Price:  QR255.44
You save:  QR72.99
P683.49
List Price:  P956.94
You save:  P273.45
KSh6,461.20
List Price:  KSh9,046.20
You save:  KSh2,585
E£2,482.03
List Price:  E£3,475.04
You save:  E£993.01
ብር6,237.86
List Price:  ብር8,733.50
You save:  ብር2,495.64
Kz45,607.24
List Price:  Kz63,853.79
You save:  Kz18,246.54
CLP$48,681.26
List Price:  CLP$68,157.66
You save:  CLP$19,476.40
CN¥362.01
List Price:  CN¥506.84
You save:  CN¥144.83
RD$3,017.61
List Price:  RD$4,224.90
You save:  RD$1,207.28
DA6,678.15
List Price:  DA9,349.94
You save:  DA2,671.79
FJ$113.48
List Price:  FJ$158.89
You save:  FJ$45.40
Q386.23
List Price:  Q540.76
You save:  Q154.52
GY$10,467.47
List Price:  GY$14,655.30
You save:  GY$4,187.82
ISK kr6,913.61
List Price:  ISK kr9,679.61
You save:  ISK kr2,766
DH499.81
List Price:  DH699.78
You save:  DH199.96
L910.32
List Price:  L1,274.52
You save:  L364.20
ден2,923.74
List Price:  ден4,093.48
You save:  ден1,169.73
MOP$401.12
List Price:  MOP$561.60
You save:  MOP$160.48
N$907.46
List Price:  N$1,270.52
You save:  N$363.05
C$1,841.10
List Price:  C$2,577.69
You save:  C$736.58
रु6,753.23
List Price:  रु9,455.06
You save:  रु2,701.83
S/189.86
List Price:  S/265.82
You save:  S/75.96
K201.41
List Price:  K281.99
You save:  K80.58
SAR187.67
List Price:  SAR262.75
You save:  SAR75.08
ZK1,384.62
List Price:  ZK1,938.58
You save:  ZK553.95
L236.44
List Price:  L331.04
You save:  L94.59
Kč1,203.80
List Price:  Kč1,685.42
You save:  Kč481.62
Ft19,537.53
List Price:  Ft27,354.11
You save:  Ft7,816.57
SEK kr551.39
List Price:  SEK kr771.99
You save:  SEK kr220.60
ARS$50,126.56
List Price:  ARS$70,181.20
You save:  ARS$20,054.63
Bs346.46
List Price:  Bs485.08
You save:  Bs138.61
COP$220,634.58
List Price:  COP$308,906.07
You save:  COP$88,271.48
₡25,407.49
List Price:  ₡35,572.52
You save:  ₡10,165.02
L1,264.30
List Price:  L1,770.13
You save:  L505.82
₲391,827.47
List Price:  ₲548,589.81
You save:  ₲156,762.34
$U2,138.81
List Price:  $U2,994.50
You save:  $U855.69
zł206.57
List Price:  zł289.22
You save:  zł82.64
Already have an account? Log In

Transcript

We are going to do some programming. So, we are doing some sandboxes or we are doing some some test environment code and after our event completed we will move to production okay. Yeah you take the batch or you made it similar or you made it trigger. So, once your logic develop complete, then you have to move that changes to the production. Okay. So now, before going into production, the functionality for what you are writing the code, then able to test it that test maybe your unit test or maybe test by the testing team.

Okay. So whenever we're doing unit tests, that means you will check the check the flow in the way you open the pages and treat the flow is working as expected or not. And secondly, you can write some piece of code to test it also. Okay, that means it does a functional testing Do we know what I'm doing unit testing? How I do? Okay, we can see what's going good.

Yeah. Whenever I'm going to do unit testing, how I do the testing programmability and what are things I need to see for the unit testing? Okay. Now, whenever I'm doing the unit testing what's going to happen? So let's see you will have written was one small program called a calculator. Okay.

In calculator, you functionally ledger isn't the only like subtraction we have completely like multiplication. So, whenever you write a unit test as per this, then you will give the input to this functionality to this method. And you will see the residual is happening as you're executing on that is it only the test incurred? If Yeah, if you are going to input five and three, four that isn't it expect the deletion to eight or not? So whenever you're going to disclose, you should write the test cases in such a way that your functionality would cover like this. Okay?

You should test for a single record. Okay, pass a single record to the diskless. Okay? And check the functional to working for is one record or not, okay? Then do testing for bulk record, okay, multiple records also and they'll in your methods, okay. Then check for the positive scenario like LTL okay.

In a past 500 to my method, inputs would be three outputs would be eight, and in the same thing, you would check the negative scenario. Okay? That means you perhaps are vibrantly ritual should not be nine. Yes, good. And also, you should choose the uteruses. That means they're sick.

Is a method, I didn't give permission to all of you just to use it, I gave only permission to you, okay? And I will check if somebody logged in, okay, who is not you? Okay, if somebody else logged into the system, then they cannot execute this method that also should test. So whenever I'm writing in this class, I should, I should write a single record public or policy scenario negative scenario, and reduces in how I am going to write it. So whenever I'm telling class, this class, that's when you're starting, but it's a simple this simple app is slow, but that class should behave as if this class Okay, so whenever you have your class and it I want it to be a class, I use some interface that is spelled watchable, or to do a user interface system does the same way. Whenever you want any class to be diskless you want to notice Color at the red is test if I notice a lot is tears in that class is going to be diskless either I think something like this he'll probably close as flat as see, if I don't have this under the sun that is just a class for you give me some wisdom.

That means you said yes to us. So whenever I take class, then using this class, I can explain logic. Okay. One more point Olivia should remember, whenever we're going to declare that you're going to deploy to production, or will production we check how much code coverage you in a sense how much this was you wrote, or you're constantly, always need at least 70 paper in the code coverage for classes, or at least 1% code coverage for the trigger. is a minimum requirement. You don't have this much code coverage and you cannot deploy the classes or two we cannot deploy any epics to the production.

Okay. Let me log into the system is So I have some templates. I have some classes for that class. I write this as a tendency. See, whenever you whenever you're going to log into sandbox, then you test yourself. Or I'm working the Developer Edition.

I'm going to log into software testing. It's a different site, is it? Yes. I extended it up About everything. So, we have one production environment which is live and all a new testing. So whenever logging is is should be login.salesforce.com okay and and also it is the party three account we have in the Developer Edition that is also you can log in in salesforce.com log in yourself.

So, now we distinguish security we have one one CRM application here and all these we are going to make something just we cannot turn the directory in production. So, we should make some education so far this person we make copy some some toner indeed. Okay. And we have different lots of different projects we have different columns, okay, now, these are I will call it sandbox. So, to log into sandbox, you should use this dot six footer okay. So now I'm in the deliberation and I look into ourselves further.

Yeah. Okay, so I have some glasses for the herniated disc. So how this is going to operate, and also how I'll see how much cool is covered in my in my class. Let's see what are the classes I have no perfect diskless I will write this position badge or this badge I'm going to write difference. And I will see how this is going to happen. So now see the code coverage universal.

Okay. So now let's see I'll see which lines covered or not by the blue console, open the developer console. classes you want to see should match then see the coverage on even today no line is covered. Okay. I'm going to discuss for this political party I'm going to do so these tests these classes are going to do it is going to take all position and in this place intelligence status, who is going to operate okay. So now I have to write coverage for this.

So now we will publish these that means it will call me intellectual and it will update the position shutters that means I should test other position records. So I should create it is for you I hope you take Lascaux okay. is okay. So now, if we'll see this class this class is normally a base class, but I want to make these editors class to make this I should give some extra behavior to this. That is by Andersen I use at the date is test the equivalence class numbered in this class okay. So, now inside this class which I should have some methods you will actually get now I will write some test methods like it this method see if I'm writing something like this public employer um let's see test one something like that that doesn't mean this maturity test or it isn't a simple method when you want to any method is better use the keyword test method already already also you can use the same as it is to some new testament on then this we will have this test material is going to change is not a simple matter which you can make a public case with regard so these methods will be static method.

Okay See, if I tried to say was killing it's really starting with them. Voice acting in the static enemy setting the first can be called a class named Only to insensitive. So to Rhonda tasteless, I'm not going to instance it in this class directly. Okay. Now this is me. So now in this judgmental what I need is to create some petition for in I can test it.

So what I'm going to do here, I'm creating a test data for setting up the Tokyo data. How we'll do so now, for my class I need something I need some paper which I will carry an electrical tape over. Let's see how I'll do this. So now I need to do the equation Can you hear me? So finding good police police shouldn't occur. So let me go here.

So what are the minimum things I need to kill the police Can you hear me? Yeah, never says sir. Okay, so I'm going to share some reasons why an infant including operations. So see so I was not able to see the test method that you have written here now you can see the poison paste. Okay, yeah, that entry. So we're going to create a new poison record and I have to specify a position name and all the informations okay.

So I got this information and he lets you save it. Eventually quiz number two is saving. Okay. I can eat and they can say no to something. I will do a lot of thing. I'm just simply telling the person never check.

Okay. So non digital puzzle. Let's see, I wrote one police Name equal to a Cheeto name fill it up anyway. So, I want to use a name we don't name it. Okay? For now, we'll just name it our job I guess.

Okay. Now insert single record. So now for this record, I don't I want to make it test. So what I'll do is so now all these I have the class which I want to test for the position bestest. So, you position restless and I want to destroy this channel, but the techniques I should call these methods. So, how will you do individually to execute this class, I need to call this object on a call center by a tensor this class of Toby's Are you We see that need to be agile.

If you've seen normal methods and what it can do p dot method name you can call it. If it's a normal normal class, where you see it as colors. Whatever you do, you integrate it using the database. Good batch Oh, this graduated. I'm just going to test this what's going to happen here. So now I'm going to dawn in his class this batch job after running Waterloo, I'm expecting for this poison pill will be changed.

Let me call it is poison. Now going into the reason I give only name field, I ran the bad job after running the batch job. I will check what I have. Apparently bad job I'm just pulling this puppy and I will see it is updated or not Hopefully we can just put t ID equal to and then we're going to system dot assert. I'm turning the petition party is Under status change, nautical on initial one, enter One intuitive line number five is script. She says, Yeah, yeah, sometimes the screen is breaking and I'm in your voice is breaking.

I can't hear you and I'm not able to see the screen. So now it's okay. Okay, so what I did, I cleared the question record here. Okay. So see here with creating the record or into only the Name field. Okay, yeah, that's what it sounds so I didn't include any value for the status change, initially status and a non trade.

So after that I ran this batch job. Okay. To run the bedroom. I used police in the capability to advise for the police and catch instances when I did an absolutely fundamental dilemma which apparently bad job so as for my battery's killing it will change this field then according to Sam record who to insert that it will poison it like go to insert here okay then I saw these prints should not be known to obliterate something okay so I'm so now I save it so once you save it then I'll run it and I will check for that thing so on this single diskless you can go on and on test that when it will run this test class only. Okay so hold on, we'll go to testing tuition paid to so if you're only gonna see you still not see anything you go here. So why is Phil assert or certainly certainly as an appraiser credit this line 11 color this is what is notable about it is till now Okay, so now it's a bad job.

So, now our job is to do in the open this bad job electrical in a synchronous mode. Okay, as soon as more in the sense you just give the operations to trigger any to start up okay. It's not going to wait for the next moment it really could continue in the opposite you know the dependent inclusions increments yeah okay. So is running in a single network discusses will run in the synchronous mode. So, in single instance to the surgeon line by line you start with intuition. But now, as I said that class is not going to execute in synchronous mode, in although lines will execute in synchronous, but only these two line eight and line is going to do coding as soon assume the most.

So now the cursor is an interesting over the nice end Okay, there should be a solution of the battable thing. We'll get it very cool as a synchronous motors, yes. It will be nothing more, then it's in back in background repurposing. No, I don't know. So in this we'll go over and before that, I may try to execute these two line decision learning in the passing grace mode. Okay?

And then I may not get this as well present, what I'm going to do, I keep everything in something called algo tester stack test. Okay, so here's a concrete stop stop. So, always remember to you see, this pattern is all about inserting my data or setting up my test. Then my actual testing cycle always you try to use this third stack test and test or stop tears in your discusses. Okay, okay. So what will the Ensure.

So, whenever you lose this case of stack test and test or stop test, it is going to execute in separate context that means, so your datacenter okay you have limitations. So, when it came here you have okay one B one a percent portfolio like this lot of system resource for you whatever you always always pointed there. Yes, yes for going ahead, this will start this this block of code, which you wrote insert static and stop this, this block of code is going to start inside this context does not take this tester status outline it for me I sent you the link also which you need to follow. See this many different portfolios you need to do Same thing we would start stop testing. Is there any mystery you can't sing? Do I need to have any class of test?

No, no nothing to do yesterday This is just method just apart from that nothing we need a dozen signatures to start this okay. All problem what is C? Basically, I wouldn't test that test. So that means this class where other mechanical detectors failed Yeah. Now I see the mistake either on these test cases system was well we were referring system class but to us On paper learning with your class enamel test also so it's trying to report you know to the test already there is a test class is it that's why it is looking for that. Good.

Okay it's a pretty good I have a class mine Okay, let me close this we'll see how many lines getting covered Hello, come here for the coverage coverage 100% So, each line which line would cover then that line is going to be set as though like is it in some electric similar will come in right now ladies with me to change factors everything to do so basically how we relate to that thing like what is the main functions it will consider is used to a PC bad job we will go back over here. Yeah, that is covered okay. So now let's consider one one small class I'm writing a small class and you can see how it's normal being for the class okay? Could be a calculator Class A simple class mostly. Okay, so now there is one small method I am going to try to tasteless parties and how it's going to happen Going to the live should be static.

Okay? We're not going to return anything. Okay, so now I need to test this one. So to take this one that means I need to call this Yes. So I'm going to instantiate it. Okay, then I need to call this one I call Sweetwater past five and three.

Okay? So now she is to return me one minute. Hello. Hello this much. Okay, so now if we find logic to properly they need to return a pipe closeable eight then now it's called or not. Then you use system dot assert equals.

You have same same thing in different assortments. Yeah, same thing. So we're expecting eight and actual values while data equals correct. Yeah, it will dispatch will fail. There's a to my expect value 10 that means my diskless would correct yes. So I ran the test, see, these tests will fail.

So that means my, in my logic, I'm excluding 10, but not giving two in that when we logically don't, but actually, I should expect it. I hear eight, okay. So if you want further negative scenario you pass on Hello. You will Okay, I want to extract this like 10 iF 10 in the sense, this is going to be negative assert not equals. So whatever it may be results will not be 10 Okay. So like this you should check it you don't just now see if I don't if I'm expecting 830 per segment I pass it info on it will give me the struggle and it will see the coverage you go to here on this class.

So, he had this class completely now called the Euro, I just refresh it she the core coverage, hundred percent okay. So now see in this test class, okay. So what do we need? We have inserted one position Yeah, so that person is not going to commit to database because it takes time to creating and doing. So, see there is no new poison created No, we don't okay. So, long as you give the name this person, they notice the composure that means, you taste classic classes not going to commit anything to database and it cannot get any information from database also, it will try to put in it this class, it will not bring the information that I was delivering the information only from the test data.

But still, you still if you want to get information from the database, then you should use something called see all data is not a good practice to use. But if you see your data you can go here you to learn So, you have to read this and understand SEO a lot a tool that means that it is going to see all the data from the system, all the questions on the system, then run the batch, but it will not commit and commit anything. Exactly we will see all that true okay. But it is not good practice to use the sealer what you can use depending on something like which color you cannot create what you want that occurred and then you can use the sealer or you can patch it. Okay. So, I will send you one link of the testing, okay.

Like so limit is out there tells you say, yeah, we'll do this. And then you know, then maybe we'll do a little keeping the same, right? Yeah, sure. Okay. Thank you tomorrow. Yes, yeah.

I just joined I thought 630s like I forgot about the data. saving time. Okay, so I taught the class that just now. So will there be a class tomorrow? Yes, yes. Yes.

Okay. So one day you couldn't join you just misses me once, okay? Yeah, sure. Oh, okay. We'll be doing Raven. You can check this also.

Yes. Okay. Thank you.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.