Amathiphu Nemikhuba Emihle Yokuhlola Ukuhlanganiswa Kwe-Salesforce

ukuhlanganiswa kwabasebenzi

Ukuhlolwa kwe-Salesforce kuzokusiza uqinisekise ukwenziwa kwakho ngendlela oyifisayo Ukuhlanganiswa kwe-Salesforce nokusebenza nezinye izinhlelo zebhizinisi. Isivivinyo esihle sihlanganisa wonke amamojula we-Salesforce kusuka kuma-akhawunti kuya ekuholeni, kusuka emathubeni kuya emibikweni, nasemikhankasweni kuya koxhumana nabo. Njengoba kunjalo ngazo zonke izivivinyo, kunendlela enhle (esebenzayo nefanele) yokwenza isivivinyo seSalesforce nendlela embi. Ngakho-ke, yini iSalesforce evivinya umkhuba omuhle?

  • Sebenzisa amathuluzi wokuhlola afanele - Ukuhlolwa kwe-Salesforce kwenzeka kusiphequluli noma endaweni esekwe yi-Eclipse. Zombili iziphequluli zakamuva kanye ne-Eclipse zinamathuluzi amahle wokulungisa amaphutha futhi ungazihlanganisa nezigaba zokuhlola ukuthola imiphumela esiza kakhulu. Kodwa-ke, uma udinga okuningi, i-Apex Interactive Debugger (noma i-Apex elula) yiFoot.com kufanele isetshenziswe. Qaphela ungasebenzisa futhi iSalesforce Lightning Inspector, isandiso se-chrome, ukuhlola ngqo iSalesforce Lightning. I-Apex iyi- Force.com ulimi lokuhlelwa kwepulatifomu olufana kakhulu neJava. Kuyinto ethambekele entweni, engenakucabangela, ethayipha ngokuqinile ulimi lohlelo olulandela abakaki abakhiqizi kanye ne-syntax yamachashazi. Ungasebenzisa i-Apex ukwenza imisebenzi ehleliwe phakathi kwezinqubo eziningi ze-Foure.com, kufaka phakathi izixhumanisi zenkinobho nezinkinobho, izibuyekezo, ukususwa, nokurekhoda abaphathi bomcimbi wokufaka ngokusebenzisa abalawuli bekhasi le-Visualforce noma ukuhlela.
  • Sebenzisa Imihlangano Efanele Yamagama - Ukuqanjwa okufanele kwezindlela zakho zokuhlola ngaphambi kokuqala ukubhala izivivinyo kubaluleke kakhulu. Igama lendlela yokuhlola kufanele libe nezingxenye ezintathu. Lawa yi-nameOfMethod (igama lendlela oyivivinya njengokufaka / ukuvuselela / ukususa / ukususa ukuyekisa lapho uvivinya i-trigger, imininingwane ngeTestPath eguquguqukayo njengokuxhumana okungekho emthethweni uma uvivinya ukuthi oxhumana naye akasebenzi, futhi isebenza lapho uhlolwa indlela enhle / engeyinhle.
  • Qinisekisa ukutholakala kwe-100% - Yize inkomba ejwayelekile ye-Salesforce ukuthi iyunithi lokuhlola kufanele libe nokufakwa okungama-75% kwekhodi yakho (kususwe amakilasi wokuhlola, izingcingo ku-System.debug nezindlela zokuhlola) futhi ngeke ukwazi ukusebenzisa i-Apex code noma izinhlelo zokusebenza ze-AppExchange zokusebenza, kufanele qaphela ukuthi lokhu kumane nje kuyizinga elijwayelekile futhi inhloso yakho kufanele ibe ukumbozwa okungu-100%. Hlola onke amacala amahle / amabi futhi uthole idatha ekhona futhi engekho. Amanye amathiphu abalulekile uma kukhulunywa ngokufakwa kwekhodi yilena:
    • Kufanele usebenzise izivivinyo ukuvuselela izinombolo zokufakwa kwekhodi ngoba lezi zinombolo azivuselelwa lapho ikhodi ye-Apex ivuselelwa kuze kube ukuhlolwa kuphindwaphindwa.
    • Uma kube nokuvuselelwa enhlanganweni kusukela kuhlolwa okokugcina, kunengozi yokuthi izinombolo zokufakwa kwekhodi zizobe zingalungile. Qalisa kabusha izivivinyo zesilinganiso esifanele.
    • Amaphesenti wokufakwa kwamakhodi awabandakanyi ukufakwa kwekhodi kusuka ekuhlolweni kwamaphakeji aphethwe, ngaphandle kokuthi kuphela lapho lezi zivivinyo zibangela umlilo.
    • Ukutholakala kuncike enanini lenombolo yamakhodi ekhodi. Uma ungeza noma ususa imigqa yekhodi, uzothinta iphesenti.
  • Amacala Okuhlola Emakilasini Nakubalawuli - Ekuthuthukisweni kwe-Salesforce, onjiniyela abaningi bakha amakilasi ahlukile namafayela wesilawuli ngomsebenzi ngamunye. Lokhu kwenzelwa ukwenza ukufaka amakhodi kuhleleke kakhudlwana, kube lula, kuphinde kusetshenziswe futhi kuphatheke. Kodwa-ke, kufanele wazi ukuthi yize lokhu kulula, akusebenzi kahle. Uzofinyelela ukuthwala uma ikhodi yokuhlola ikusigaba sokuqala kanye nekhodi yokulawula uqobo ngoba ngeke uphuthelwe kunoma yiliphi ikilasi lokuhlola lapho uthuthela usuka ku-sandbox uya ekukhiqizeni.
  • Sebenzisa i-System.assert () - Ku-Apex, Isistimu.assert() isetshenziselwa ukubheka izimo. Lokhu ukusebenza okubalulekile ngoba kukuvumela ukuthi unqume ukuthi ngabe umsebenzi othile wenziwe ngendlela njengoba bekulindelwe. Kufanele usebenzise iSystem.assertEquals () kanye neSystem.assertNotEquals () phakathi kokusebenza okubucayi akusizi nje kuphela ukuthola ukuthi ikhodi yenziwe ngendlela efanele, kepha futhi nokuqinisekisa ukuthi ayikho idatha ebhalwe ngephutha uma ikhodi ingahambi kahle.
  • Isivivinyo Esiphelele - Ukuhlola kufanele kufake yonke into. Kufanele wenze ukuhlolwa kokusebenza, ukuhlolwa komthwalo, ukuhlolwa kokuphepha, nokuhlolwa kokuthunyelwa.
  • Ukuhlolwa Kweyunithi - Kufanele ube nokuhlolwa kwamayunithi ukuqinisekisa ukuthi amarekhodi angawodwana akhiqiza umphumela olungile nolindelekile. Ngenkathi usebenzisa isivivinyo esikhulu esihlanganisa yonke ikhodi kungahle kubonakale kuwumqondo omuhle, qaphela ukuthi imiphumela ekhiqizwayo iyoba nzima ukulungisa iphutha futhi ukwehluleka kuzoba nzima ukuyiqonda. Ukuhlolwa kweyunithi kufanele kufake i-subset encane yokusebenza okuvivinywayo.
  • Amacala Wenqwaba Yokuhlola - Ikhodi yokuhlola enhle (i-trigger, ngaphandle, noma isigaba) ingabandakanywa kuze kufike kumarekhodi angamakhulu amaningana (200 we-Apex). Kufanele usebenzise ngokunenzuzo lokhu futhi ungavivinyi amarekhodi angabodwana kuphela, kepha namacala amaningi.
  • Izivivinyo Ezinhle - Hlola ukuqinisekisa ukuthi ukuziphatha okulindelekile kwenzeka ngayo yonke imvume elindelekile. Isivivinyo kufanele siqinisekise ukuthi umsebenzisi ugcwalise ifomu ngendlela efanele nokuthi akazange adlule imikhawulo.
  • Ukuhlolwa Okubi - Hlola amacala amabi ukuqinisekisa ukuthi imilayezo yamaphutha ikhiqizwa kahle. Izibonelo zamacala anjalo amabi azikwazi ukucacisa amanani amabi futhi azikwazi ukwengeza amadethi azayo. Ukuhlolwa okungekuhle kubalulekile ngoba ukuphatha okuyikho lapho izinto ziya eningizimu kungenza umehluko.
  • Shintsha Ukuhlola - Ngokwesiko, ukuhlolwa kwabakwaSalesforce bekungokwenziwa ngesandla. Kufanele ucabangele ukuhlolwa okuzenzakalelayo njengoba lokhu kunikeza izinzuzo eziningi. Lokhu kufaka phakathi:
    • Ukuhlolwa okwenziwa ngesandla kukwenza uthambekele emaphutheni ngoba ukuhlolwa kungabantu hhayi amarobhothi. Amarobhothi enza kahle emisebenzini ephindaphindwayo ngenkathi abantu benza amaphutha ngenxa yesithukuthezi, ukunciphisa ukugxilisa ukungaguquguquki nokungaguquguquki, nokuthambekela kokusika amakhona.
    • Ukuhlolwa okwenziwa ngesandla kuyaphindaphindeka, kuyindlela yokwenza futhi kuyakhathaza. Ithimba lokuhlola lingcono ngokwenza umsebenzi ohlola kakhulu.
  • Yenza igatsha ngalinye le-Code Logic - Lapho usebenzisa i-logic enemibandela (lapho ufake ama-opharetha we-ternary), igatsha ngalinye lomqondo wekhodi kufanele lenziwe.
  • Sebenzisa okokufaka okungavumelekile nokuvumelekile kwezingcingo zezindlela - Izingcingo zezindlela kufanele zenziwe kokufaka okungavumelekile nokuvumelekile.
  • Qedela Ukuhlolwa - Qiniseka ukuthi izivivinyo ziqedwa ngempumelelo - akufanele zenziwe ngokungafani ngaphandle kokuthi kulindeleke amaphutha. Phatha konke okwehlukile okubanjiwe - ukubabamba akulungile ngokwanele.
  • Sebenzisa ukuhleleka ngamagama angukhiye - Ukuqinisekisa ukuthi amarekhodi akho abuyiswa ngendlela olindele ngayo, sebenzisa i-ODA NGAMAgama angukhiye.
  • Ungacabangi ukuthi ama-ID amaRekhodi ahlelwe ngokulandelana - Gwema iphutha elejwayelekile lokuthatha ama-ID werekhodi ahlelwe ngokulandelana. Omazisi abalandelani, ngaphandle kokuthi ufake amarekhodi amaningi ngesicelo esifanayo.
  • Shayela i-Test.startTest () neTest.stopTest () - Uma wenza isivivinyo seyunithi ye-Apex, uzothola ngaphezu kokufakwa kwekhodi okungu-75% okuphoqelekile ku-Salesforce. Kufanele ushayele i-stopTest ngaphambi kokuqinisekiswa ukuze uphoqelele amakhodi we-asynchronous okungenzeka asasebenza ukuqedela. Qalisa imibuzo emisha yemiphumela yokugcina ngoba enye ikhodi ingashintsha idatha. UsebenzisaTest.startTest () kanye ne-Test.stopTest () kukuqinisekisa nge-sandbox isivivinyo ngaphakathi kwemikhawulo yaso yombusi. Ngale ndlela, ikhodi yokusetha oyisebenzisayo ngeke iphazamise futhi ikunikeze okungeyikho kwamanga noma okuhle okuzungeze umkhawulo wombusi. I-Test.stopTest () nayo iqinisekisa ukuthi izingcingo ze- @ future zizophelelela ukuhlolwa.
  • Ukufundeka - Ukufundeka kubaluleke kakhulu ekuhlolweni kweyunithi. Amagama wokuhlola kufanele afake isenzo esithile esizothathwa nomphumela olindelekile. Indlela kufanele ichaze futhi ibe mfushane. Indlela kufanele ibe ngendlela yokuthi iphinde isebenze ekuvivinyweni okuhlukile.
  • Yakha Amasethi Wedatha Elikhulu ngaphambi kokuqalaTest - Njengoba izivivinyo zakho zizosebenza ezindaweni ezahlukahlukene ze-sandbox nezindawo zokukhiqiza, yakha amasethi wedatha yokuhlola amakhulu ngaphambi kokuthi ushayele i-StartTest ukuqinisekisa ukuthi isivivinyo sinemikhawulo ephelele yokwenza. Ngephutha, I-Salesforce Github isebenzisa izivivinyo ezihlukaniswe nedatha yokukhiqiza. Lapho udinga idatha yohlelo efana nePhrofayili, umbuzo ukuthola into efanele leyo ndawo ethize.
  • Khiqiza Idatha Yakho Yokuhlola - Idatha yokuhlola oyisebenzisayo kufanele yenziwe esivivinyweni. Ungakhipha le datha usebenzisa isichasiselo se- @ testSetup kanye nesigaba seTestUtils ukuze ungaqinisekisi nje kuphela ukuthi unedatha efanele, kepha futhi nokuqinisekisa ukuthi zonke izivivinyo zenziwa kusandbox kanjiniyela ngaphandle kwesidingo sedatha.
  • Gwema ukusebenza kwe-AKA null - Abahloli abaningi basebenzisa i-no-op AKA null operation. Lawa ngamakhodi angenamsebenzi angenzanga lutho. Njengoba sezivele zisezingeni lekhodi yakho, zizokwengeza kumaphesenti akho okuhlanganisa.
  • Ukwenza Ukuhlola Okufanayo - Uma uqala izivivinyo kusuka kusixhumi esibonakalayo somsebenzisi we-Salesforce noma i-Developer Console, izivivinyo zizosebenza ngokufana. Lesi isici esibalulekile njengoba sisheshisa isikhathi sokuhlolwa. Kodwa-ke, kufanele wazi ukuthi lokhu kungaholela kuzinkinga zokuphikisana kwedatha futhi uma usola ukuthi lokhu kungenzeka, cisha ukwenziwa okufanayo. Izimbangela ezivame kakhulu zezinkinga zokuphikisana kwedatha okuvame ukuholela kumaphutha we-UNABLE_TO_LOCK_ROW yilezi:
    • Lapho izivivinyo zenzelwe ukuvuselela amarekhodi afanayo ngasikhathi sinye. Ukuvuselelwa kwamarekhodi afanayo kuvame ukwenzeka lapho izivivinyo zingazenzeli idatha yazo.
    • Lapho kunenkinga ekuvivinyweni okusebenza ngokufana futhi bazama ukudala amarekhodi anamanani enkambu afanayo enkomba. Ukungqubuzana kuzokwenzeka lapho izivivinyo ezi-2 ezisebenzayo zifakwe kulayini wokubuyisa idatha (lokhu kwenzeka lapho amarekhodi wokufaka wokuhlola ama-2 anamanani enkambu ayingqayizivele ayingqayizivele kuma-oda ahlukile).
    • Ukucima ukwenziwa kokuhlolwa okufanayo, iya ku-Isethaphu, faka i-Apex Test, iya engxoxweni yezinketho ze-Apex Test Execution, khetha okuthi Khubaza Ukuhlolwa Kwe-Apex Parallel, qhafaza KULUNGILE.

Khubaza ukuhlolwa okufana ne-Apex

Qasha umlingani walo msebenzi ngoba uzoba nolwazi nokuqeqeshwa okudingekayo ukuze enze isivivinyo esihle, esikunikeza nokuthula kwengqondo. Ukuqasha i-pro kukuvumela ukuthi ugxile ebhizinisini lakho eliyinhloko. Iphinde ikongele imali ngoba uzobe ungadingi iqembu langaphakathi kulo msebenzi.

UCABANGANI?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda ukuthi idatha yakho yokuphawula isetshenziswa kanjani.