Dab tsi yog qhov kev lees paub yuam kev hauv JUnit?
Dab tsi yog qhov kev lees paub yuam kev hauv JUnit?

Video: Dab tsi yog qhov kev lees paub yuam kev hauv JUnit?

Video: Dab tsi yog qhov kev lees paub yuam kev hauv JUnit?
Video: Xwm Kab Yog Dab Tsi?: Hmoob Nkag Siab Yuam Kev Tag Lawm 2024, Kaum ib hlis
Anonim

Lub built-in kev lees paub mechanism ntawm JUnit yog muab los ntawm chav kawm org. 1 Qhia #fail() throws ib kev lees paub yuam kev unconditionally. Qhov no tuaj yeem pab tau txhawm rau txheeb xyuas qhov kev xeem tsis tiav lossis kom ntseeg tau tias qhov kev cia siab tau raug muab pov tseg (saib Cov Lus Qhia Tshwj Xeeb Hauv Cov Qauv Xeem).

Hauv qhov no, qhov kev lees paub yuam kev yog dab tsi?

Ib kev lees paub yuam kev muab pov thaum hais tias "Koj tau sau ib tsab cai uas yuav tsum tsis txhob ua txhua tus nqi vim hais tias raws li koj logic nws yuav tsum tsis txhob tshwm sim. Tab sis yog nws tshwm sim ces pov AssertionError . Thiab koj tsis ntes nws." Hauv qhov xwm txheej zoo li no koj pov ib qho Kev lees paub yuam kev.

Ib tug kuj yuav nug, dab tsi yog qhov kev lees paub hauv chav kuaj? Ib kev lees paub yog ib qho kev qhia boolean ntawm ib qho tshwj xeeb hauv qhov kev pab cuam uas yuav muaj tseeb tshwj tsis yog tias muaj kab laum hauv qhov program. A xeem kev lees paub yog txhais raws li ib qho kev qhia, uas encapsulates ib co testable logic teev txog ib lub hom phiaj nyob rau hauv xeem.

Ib yam li ntawd, peb puas tuaj yeem ntes qhov kev lees paub yuam kev?

Handling ib AssertionError Chav kawm AssertionError txuas ntxiv yuam kev , uas nws tus kheej extends Throwable. Qhov no txhais tau tias AssertionError yog ib qho unchecked kev zam. Yog li cov txheej txheem uas siv kev lees paub tsis tas yuav tsum tshaj tawm lawv, thiab kev hu xov tooj ntxiv yuav tsum tsis txhob sim thiab ntes lawv.

Dab tsi yog qhov kev lees paub yuam kev hauv selenium?

Selenium Cov Lus Qhia tuaj yeem yog peb hom: " hais ”, “tso pov thawj”, thiab “tos rau”. Thaum ib qho " hais ” ua tsis tiav, qhov kev xeem raug rho tawm. Thaum qhov "tuaj xyuas" ua tsis tiav, qhov kev sim yuav txuas ntxiv ua tiav, nkag mus rau qhov tsis ua tiav. Ib lo lus txib "waitFor" tos rau qee qhov xwm txheej los ua qhov tseeb.

Pom zoo: